Upload
sharib-ahmad
View
57
Download
4
Tags:
Embed Size (px)
Citation preview
1 | P a g e
DNN UserGroup - Mar 11 2009 Meeting
Topic: Linq and DNN Reporting Presentation Part 3
Speaker: Paul Chu ( Senior Web Consultant )
Contact: [email protected]
Last Time, we saw how to utilize our Linq DAL layer containing
our RSVP tables Data Model.
We showed diagrams to show how the Microsoft ReportViewer
control can be used to Host Local Reports ( .rdlc ) files.
SHOW DIAGRAMS
We showed how the Presentation Layer can request data from our
Business Layer Method which access the Linq DAL layer.
We showed how to create reports but did not finish.
Future Meetings :
4/??/09 – asked Lynn Langit to speak on DNN project for Ministry
of Health ( Government) in Zambia, Africa.
Report Viewer Tip:
http://www.gotreportviewer.com/
Bummer: You cannot use the VS 2008 BI Server Report Project
generated RDL reports as local reports ( .RDLC )
2 | P a g e
It may be possible to tweak the XML of the RDL to convert to
RDLC compatible ( but BI 2008 has Tablix and other features )
that are NOT in the VS 2005 / ReportViewer Control based .RDLC
file.
3 | P a g e
Mar 11, 2009 - Presentation Goals – DNN Reporting Part 3
This time, we continue our discussion to cover:
1. Review of the RSVP Reporting Module DNN Package which
can be installed on a DNN website.
a. Demo RSVP Module again !
b. Demo installing the Module on a clean DNN 4.9.2
website
2. This module is the reporting component only and does NOT
have the RSVP Form page and Admin Pages.
3. Create the Master/Detail Report / Sub Reports from Scratch.
4. Show off more Linq queries.
5. How to do a Master Detail with ListViews and Linq
Q. When installing our DNN RSVP Reporting Module that has
DLLs ( such as our Linq DLL and Business Layer DLL ) how are
they deployed ?
Q. What is the DNN Manifest File ( .dnn ) ?
This file is created by DNN when you “Create a Module Definition”
in the Admin page
This XML file contains a list of “objects/Files” used by the Module.
SHOW .dnn file EXAMPLE IN APPENDIX
Q. Module Installation: How do we install the initial RSVP Tables
and populate with Data ?
4 | P a g e
SHOW Provider file EXAMPLE IN APPENDIX
Q. What are the pre-requisites for the DNN Reporting Module ?
A. Uses MS ReportViewer control which must be install on the
Hosting DNN Website. This means that the GAC has the RV dlls.
B. The DNN website web.config must also reference the RV dlls
and have the Asp.Net 3.5 references to Linq.
Attach sample web.config.sample to download
5 | P a g e
Testing RSVP Report Module 1.18 zip file on new DNN 501
website
Download 501 install zip
Install – update SiteSqlServer in Web.config
Create Database DNN501
Create Virdir to DNN501 to install folder
Create page: ReportViewerTest.aspx
Drag ReportViewer control to update web.config
Open website with VS 2008
Say yes to upgrade the Project to Asp.Net 3.5 to put Linq dlls
etc in web.config
Install RSVP Report Module but putting it on a page fails.
Error: RSVPReport is currently unavailable. DotNetNuke.Services.Exceptions.ModuleLoadException: c:\DNN4\DotNetNuke_Community_05.00.01_Install\DesktopModules\RSVPReport\View.ascx.cs(22): error CS0246: The type or namespace name 'RSVPBLL' could not be found (are you missing a using directive or an assembly reference?) ---> System.Web.HttpCompileException: c:\DNN4\DotNetNuke_Community_05.00.01_Install\DesktopModules\RSVPReport\View.ascx.cs(22): error CS0246: The type or namespace name 'RSVPBLL' could not be found (are you missing a using directive or an assembly reference?) at System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath) at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile) at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile) at System.Web.Compilation.BuildManager.GetVPathBuildResult(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile) at System.Web.UI.TemplateControl.LoadControl(VirtualPath virtualPath) at System.Web.UI.TemplateControl.LoadControl(String virtualPath) at DotNetNuke.UI.ControlUtilites.LoadControl[T](TemplateControl containerControl, String ControlSrc) at DotNetNuke.UI.Modules.ModuleHost.LoadModuleControl() --- End of inner exception stack trace ---
Forgot to add DLLs to the manifest file
7 | P a g e
Mar 11, 2009 Raffle
1. CodeSmith License Lewis
2. Telerik RAD Controls
Paul
3. Mandeep Singh – DNN Controls Walter
4. LearnVisualStudio.Net video subscription
5. Training Spot – Sql video subscription
Darcy
6. Nevron Chart Controls Subscription
Don
7. Book1
8. Book 2
9. Book 3
8 | P a g e
DNN UserGroup - Feb 11 2009 Meeting
Topic: Linq and DNN Reporting Presentation Part 2
Speaker: Paul Chu ( Senior Web Consultant )
Contact: [email protected]
Last Time, we created a Class Library Project and added the Linq
DBML to access of RSVP tables. The Project Build created a RSVP
DBML DLL with the generated Linq to Sql Classes.
We utilized this RSVPLinq.dll in LinqPad to allow us to run Linq
queries using the same Linq DataContext.
This allows us to write and test queries in LinqPad and then paste
back into our code.
Future Meetings :
3/11/09 Speaker – asked Daniel Egan to speak on Linq ?
If not ? who will step up ?
4/??/09 – asked Lynn Langit to speak on DNN project for Ministry
of Health ( Government) in Zambia, Africa.
DNN was chosen as an alternative to Sharepoint.
Volunteer to get Speakers ?
Presentation Goals
Concepts:
Demo the use of 3 Tier Design for a RSVPReport Module.
1. Why is Linq and LinqPad (with intellisense) Cool ?
9 | P a g e
// Why is Linq Cool ? It knows relationships
// you need to define those in your DB Schema
var xNoJoins = from x in RSVPLogs
where x.RsvpEventId == 1
select new {
x.LastName
, x.FirstName
, x.RSVPStatus.RSVPStatusDesc
, x.RsvpEvent.EventName
};
xNoJoins.Dump();
/*
SELECT [t0].[LastName],
[t0].[FirstName], [t1].[RSVPStatusDesc],
[t2].[EventName]
FROM [RSVPLog] AS [t0]
INNER JOIN [RSVPStatus] AS [t1] ON
[t1].[RSVPStatusId] = t0].[RsvpStatusId]
INNER JOIN [RsvpEvent] AS [t2] ON
[t2].[RsvpEventId] = [t0].[RsvpEventId]
WHERE [t0].[RsvpEventId] = @p0
*/
10 | P a g e
2. Visio Diagrams ( see separate .vsd file )
a. N-Tier Architecture Diagram – show Layers
i. Data Access Layer with Linq DBML
The Linq Data Access Layer is here: This code will “talk” sql
to the Database.
11 | P a g e
ii. Business Layer with Linq Queries
iii. UI Layer call Business Layer to retrieve data
13 | P a g e
b. ReportViewer / Report ( rdlc ) / Web Page / DataSets
relationship Diagram
i. ReportViewer is configured for a Local Report .rdlc
ii. Local Report .rdlc file is XML file and defines the
associated DataSource ( DataSet ) created at
design time
c. Developer PC ReportViewer Configuration
i. Install ReportViewer.exe
ii. Web.Config is updated for ReportViewer dlls when
dragging ReportViewer control to a page
iii. IIS 7 must grant access to ReportViewer HTTP
handler
ReportViewer / IIS 7 Configuration Article
http://otkfounder.blogspot.com/2007/11/solving-reportviewer-rendering-issue-
on.html
Vista Ultimate Resolution:
Open Internet Information Services (IIS) Manager and select your Web application.
Under IIS area, double-click on Handler Mappings icon. At the Action pane on your right, click on Add Managed Handler.
14 | P a g e
At the Add Managed Handler dialog, enter the following: Request path: Reserved.ReportViewerWebControl.axd Type: Microsoft.Reporting.WebForms.HttpHandler Name: Reserved-ReportViewerWebControl-axd
Click OK.
Fixed Report Module pages references to
Using RSVP; to Using RSVPReport;
RSVP.RSVPUtil .xxx to RSVPReport.RSVPUtil.xxx
+ Drill Down Report – Image is missing
Fix: change Image Path to
DesktopModules\RSVPReport\Img\Plug.png or minus.png
+ Send RSVP Module Package for Testing
DNN 5.01 RSVP Module Testing Completed !
Sat –
Review Practice pages in Demo folder
Review main RSVP report
Review Nested ListView
Review Nested GridView
d. DNN Report with ReportViewer Deployment to Hosted
Website
i. Install ReportViewer.exe
ii. Update Web.Config
15 | P a g e
iii. Setup IIS 7 Security
iv. Install DNN Report Module ( uses ReportViewer )
3. Business Layer with static methods using Linq Queries to the
DAL layer.
4. UI Layer ( DNN Module ) making calls to methods on the
Business Layer and databinding to our Reports.
5. Create a Simple Report using Visual Studio 2008 Report
template
6. Create a DataSource: DataSet
7. Demo the use of Images in Reports ( Dilbert Example ) –
embedded , url
8. Demo use of Linq queries in Business Layer and use of
IQueryable object to return data to the UI Layer
9. Linq Queries
a. Linq Group By query
b. Linq Left outer join
10. SSRS Report
a. SubReport ( nested in a Main Report )
b. Images
c. Formatting using VB.Net Expresssions
i. Footer – page x of y
ii. Show Date without time
iii. Alternate color
16 | P a g e
11. SSRS Reporting Example
a. Show accessing Linq query methods in Business Layer
b. Code to Bind to Report in ReportViewer
c. Code to Bind to SubReports in Report
Sample Report using Images / Background Image with Linq
17 | P a g e
N-Tier design with ReportViewer Benefits:
1. The UI Layer does NOT access the Database directly and
uses the Business Layer to get data.
2. Business Layer is reusable and can be accessed from
Winforms / WebServices etc.
3. Business Layer can be Unit Tested independent of UI Layer.
4. SSRS LocalReports don’t require Reporting Services
website. You can host these reports in your website.
5. It can provide a web based reporting presence with the
ability to export to PDF and Excel.
Disadvantages:
1. Building LocalReports is more difficult than using the
Business Intelligence Report Visual Studio Template which
creates Reporting Server Deployable reports .rdl instead
of .rdlc.
2. When Authoring a Report you do NOT have the PREVIEW
tab like in BI development mode. You must build a Page
with a Report Viewer and attach the Report and optionally
do data retrieval to populate the report.
18 | P a g e
RSVP Attendance Report using Nested ListViews
++ The Outer ListView is built from this part of the Linq Query
select new { EventDate = g.Key.EventDate, EventName
= g.Key.EventName, Speaker = g.Key.Speaker, Location =
g.Key.Location, RsvpCount = g.Count(), AttendCount =
g.Sum(x => x.AttendFlag), RSVPLogs = g }
++ The Nested ListView is built from DataSource at runtime.
<asp:ListView ID="ListView2" runat="server"
DataSource='<%# Eval("RSVPLogs") %>' > <LayoutTemplate>
19 | P a g e
Where Eval(“RSVPLogs”) refers to the nested anonymous
Type RSVPLogs ( Collection ) returned by the Linq Query.
select new { EventDate = g.Key.EventDate, EventName =
g.Key.EventName, Speaker = g.Key.Speaker, Location = g.Key.Location,
RsvpCount = g.Count(), AttendCount = g.Sum(x => x.AttendFlag), RSVPLogs = g }
The complete Linq query: joins 3 tables and uses a GROUP BY
With:
RsvpCount = g.Count()
, AttendCount = g.Sum(x => x.AttendFlag)
from p in ctxRSVP.RSVPLogs
from s in ctxRSVP.RSVPStatus
from evt in ctxRSVP.RsvpEvents
where p.RsvpStatusId == s.RSVPStatusId
&& p.RsvpEventId == evt.RsvpEventId
orderby p.RsvpEventId, p.AttendFlag descending, p.RsvpDate
select new { evt.EventDate, evt.EventName, evt.Speaker,
evt.Location, p.FirstName, p.LastName, p.RsvpEmail,
p.AttendFlag, p.RsvpDate, p.RsvpLogID, p.RsvpEventId,
s.RSVPStatusDesc }
into grp
group grp by new { grp.EventName,
grp.Speaker, grp.Location, grp.EventDate }
into g select new { EventDate = g.Key.EventDate, EventName =
g.Key.EventName, Speaker = g.Key.Speaker, Location =
g.Key.Location, RsvpCount = g.Count(), AttendCount =
g.Sum(x => x.AttendFlag), RSVPLogs = g }
Copy and Paste this into LinqPad to Test !!!
20 | P a g e
Remember in LinqPad we need to have reference the Linq…DLL
in order to use our own DataContext !
Refer to Linq example:
RSVPTest3Statements.Linq
23 | P a g e
+ Left Outer Join Example – when you want to include all
rows from the main table and join to the second table if
there are any rows found.
The Left Outer Join syntax in Linq is not very intuitive but
here is an example ( I don’t know how to use the
GroupJoin yet) –
… join … on … into … from … in …DefaultIfEmpty()
var v1 = (
from x in CRISII_FundingSources
join y in CRISII_Funding_Slots
on x.FundingID equals y.FundingID
into xy
from x2 in xy.DefaultIfEmpty() orderby x.FundingDescription
select new { x.FundingDescription, SlotCount =
xy.Count() }
).Distinct();
v1.Dump();
NOTICE: no Group By in the generated Sql
SELECT DISTINCT [t3].[FundingDescription], [t3].[value] AS [SlotCount] FROM ( SELECT [t0].[FundingDescription], ( SELECT COUNT(*) FROM [CRISII_Funding_Slot] AS [t2] WHERE [t0].[FundingID] = [t2].[FundingID] ) AS [value] FROM [CRISII_FundingSource] AS [t0]
24 | P a g e
LEFT OUTER JOIN [CRISII_Funding_Slot] AS [t1] ON [t0].[FundingID] = [t1].[FundingID] ) AS [t3] -- Context: SqlProvider(Sql2008) Model: AttributedMetaModel
Build: 3.5.30729.1
25 | P a g e
Linq supports the old way and new way !
// Linq query with Explicit Joins ( old way of
thinking )
var coll1 =
from p in ctxRSVP.RSVPLogs
from s in ctxRSVP.RSVPStatus
from evt in ctxRSVP.RsvpEvents
where p.RsvpStatusId == s.RSVPStatusId
&& p.RsvpEventId == evt.RsvpEventId
orderby p.RsvpEventId, p.AttendFlag
descending, p.RsvpDate
select new { evt.EventDate, evt.EventName,
evt.Speaker, evt.Location, p.FirstName,
p.LastName, p.RsvpEmail, p.AttendFlag,
p.RsvpDate, p.RsvpLogID, p.RsvpEventId,
s.RSVPStatusDesc }
into grp
group grp by new {
grp.EventName, grp.Speaker, grp.Location,
grp.EventDate } into g
select new {
EventDate = g.Key.EventDate, EventName =
g.Key.EventName, Speaker = g.Key.Speaker,
Location = g.Key.Location, RsvpCount = g.Count(),
AttendCount = g.Sum(x => x.AttendFlag), RSVPLogs
= g }
;
26 | P a g e
coll1.Dump("Linq query with Explicit Joins ");
// Here we remove the explicit JOINS, Linq knows!
var coll2 =
from p in ctxRSVP.RSVPLogs
orderby p.RsvpEventId, p.AttendFlag descending,
p.RsvpDate
select new { p.RsvpEvent.EventDate
, p.RsvpEvent.EventName
, p.RsvpEvent.Speaker
, p.RsvpEvent.Location , p.FirstName, p.LastName, p.RsvpEmail,
p.AttendFlag, p.RsvpDate, p.RsvpLogID,
p.RsvpEventId
, p.RSVPStatus.RSVPStatusDesc } into grp
group grp by new { grp.EventName,
grp.Speaker, grp.Location, grp.EventDate } into g
select new { EventDate = g.Key.EventDate,
EventName = g.Key.EventName, Speaker =
g.Key.Speaker, Location = g.Key.Location,
RsvpCount = g.Count(), AttendCount = g.Sum(x =>
x.AttendFlag), RSVPLogs = g }
;
coll2.Dump("Cut and Paste Test, no explicit
joins");
27 | P a g e
LinqPad also does SQL too ! Run this changing Language to
Sql
// change language dropdown to SQL !!! first
//here’s our report query the old fashioned sql way !
select b.EventDate as EventDate
, b.EventName ,b.Speaker, b.Location
, count(*) as RSVPCount
, sum ( case a.AttendFlag when 1 then 1 Else 0 End)
as AttendCount
, sum ( isnull(a.AttendFlag, 0)) as AttendCount2
, sum ( case c.RSVPStatusDesc when 'I will attend'
then 1 else 0 end ) as Attending
, sum ( case c.RSVPStatusDesc when 'I''m a maybe'
then 1 else 0 end ) as Maybe
, sum ( case c.RSVPStatusDesc when 'I will NOT
attend' then 1 else 0 end ) as NotAttending
, sum ( case c.RSVPStatusDesc when 'Walk In' then 1
else 0 end ) as WalkIn
, b.RSVPEventId
from rsvplog a, rsvpevent b, rsvpstatus c
where a.rsvpeventid = b.rsvpeventid
and a.rsvpstatusid = c.rsvpstatusid
and a.rsvpstatusid not in ( 3,4 ) -- exclude status I
will not attend, cancellation of RSVP
group by b.EventDate , b.EventName , b.RSVPEventId,
b.Speaker, b.Location
order by b.EventDate desc
28 | P a g e
Make sure you have “C# Statement” Mode in the dropdownlist
And add code to setup our DataContext.
string strConn = @"Data Source=.\sql2005;Initial
Catalog=DNN482;Integrated Security=True";
RSVP.Dnn482LinqDataContext ctxRSVP = new
RSVP.Dnn482LinqDataContext(strConn);
Where: RSVP.Dnn482LinqDataContext is the NameSpace
and ProjectName with DataContext appended
29 | P a g e
Paul’s Homework: Create a zip file of Reporting Module and Class Libraries And Database for Part 3 next month Feb 2009 Raffle
10. CodeSmith License Andy
11. Camtasia License NONE
12. Telerik RAD Controls Darcy
13. Mandeep Singh – DNN Controls Paul
14. LearnVisualStudio.Net video subscription
???
15. Training Spot – Sql video subscription
Henry
16. Nevron Chart Controls Subscription
NONE
17. Book1
18. Book 2
19. Book 3
30 | P a g e
DNN Jan 14 2009 Presentation
Topic: DNN Reporting / Linq vs Sql
Linq To Sql – we utilize the power of Linq queries for Report
DataBinding.
LinqPad ( Query Analyzer for Linq ) is free !
http://www.linqpad.net/
http://oreilly.com/pub/e/909 - video here
45 blurry minutes of Joesph Albahari
We use LinqPad to “learn Linq” syntax.
LinqPad has a $20 version which includes Intellisense
Expression Mode ( single statement )
Statement Mode ( C# code snippets )
LinqDataContext built in
myResult.Dump();
Linq concepts
LinqDataContext
Var xxx vs IQueryable xxx
Lambda Expressions ( shown in Linq Output Window)
Linq “Group By” query vs. TSql Group By
Sum, Count, Distinct using Linq
Inner Joins
Switch to Sql Mode to run standard Sql Statements
31 | P a g e
How’s your Sql Reporting ? SAMPLE Reporting SQL using GROUP BY and sum ( case … ) alter procedure [dbo].[RSVPAttendanceCounts]
as
begin
-- Show Year / Month / EventName - Show Attendance and
RSVP Record Counts by Event ( don't count -
cancellations, not attend status )
-- exec RSVPAttendanceCounts
-- select * from RSVPStatus
set nocount on
select b.EventDate as EventDate
, b.EventName ,b.Speaker, b.Location
, count(*) as RSVPCount
, sum ( case a.AttendFlag when 1 then 1 Else 0 End) as
AttendCount
, sum ( isnull(a.AttendFlag, 0)) as AttendCount2
, sum ( case c.RSVPStatusDesc when 'I will attend'
then 1 else 0 end ) as Attending
, sum ( case c.RSVPStatusDesc when 'I''m a maybe' then
1 else 0 end ) as Maybe
, sum ( case c.RSVPStatusDesc when 'I will NOT attend'
then 1 else 0 end ) as NotAttending
, sum ( case c.RSVPStatusDesc when 'Walk In' then 1
else 0 end ) as WalkIn
, b.RSVPEventId
from rsvplog a, rsvpevent b, rsvpstatus c
where a.rsvpeventid = b.rsvpeventid
and a.rsvpstatusid = c.rsvpstatusid
and a.rsvpstatusid not in ( 3,4 ) -- exclude status I
will not attend, cancellation of RSVP
group by b.EventDate , b.EventName , b.RSVPEventId,
b.Speaker, b.Location
order by b.EventDate desc
-- the end --
end
32 | P a g e
Q.How do we create a similar GroupBy query using Linq ?
Q. How do we Bind our Linq queries to Web Controls such as ListView / GridView and SSRS Reports at runtime ?
Q. How do bind a query to SSRS SubReports ?
Q. What is the advantage of using Linq queries vs DataSets
( well, if you want to rework the query for Datasets you have to start over ??? )
33 | P a g e
LINQPAD – Statement Mode with C# language is more powerful
Than Expression mode
Creating a Context variable:
ctxGRS.GRSDataContext ctx = new
ctxGRS.GRSDataContext("Data Source=USER1-PC;Initial
Catalog=DNNCRISII;Integrated Security=True");
Goal: We want to write C# Linq code that can be used directly in our C# projects with the Linq DataContext Object references.
By default, LINQPAD creates an internal DataContext that enables writing Linq queries without specifying a context object.
string strConn = @"Data Source=.\sql2005;Initial
Catalog=DNN482;Integrated Security=True"; // provide a Connection
string
RSVP.Dnn482LinqDataContext ctx = new
RSVP.Dnn482LinqDataContext(strConn); // create ctx object passing in a
valid connection string to the constructor
34 | P a g e
+ Left Outer Join Example
The Left Outer Join syntax in Linq is not very intuitive but
here is an example ( I don’t know how to use the
GroupJoin yet)
var v1 = (
from x in CRISII_FundingSources
join y in CRISII_Funding_Slots
on x.FundingID equals y.FundingID
into xy
from x2 in xy.DefaultIfEmpty() orderby x.FundingDescription
select new { x.FundingDescription, SlotCount = xy.Count() }
).Distinct();
v1.Dump();
NOTICE: no Group By in the generated Sql
SELECT DISTINCT [t3].[FundingDescription], [t3].[value] AS [SlotCount]
FROM (
SELECT [t0].[FundingDescription], (
SELECT COUNT(*)
FROM [CRISII_Funding_Slot] AS [t2]
WHERE [t0].[FundingID] = [t2].[FundingID]
) AS [value]
FROM [CRISII_FundingSource] AS [t0]
LEFT OUTER JOIN [CRISII_Funding_Slot] AS [t1] ON [t0].[FundingID] = [t1].[FundingID]
) AS [t3]
-- Context: SqlProvider(Sql2008) Model: AttributedMetaModel Build: 3.5.30729.1
35 | P a g e
Linq to XML ( see samples with LinqPad )
You can easily create, load and update XML files.
XElement settings =
new XElement ("settings",
new XElement ("timeout", 30)
); // create new XML tree
settings.Dump ("Original XML - we create simple Xml");
settings.Element("timeout").SetValue(90); // update the
timeout from 30 to 90
settings.SetElementValue("timeout", 999 ); // update again
with different method
settings.Add( new XElement ( "timeout2", 111)); // add
another elemeent timeout2
//settings.SetValue ("blah");
settings.Dump ("Notice timeout changed from 30 to 90 to
999");
settings.Save("Linqpad_SetValueReplacesChidCntent.xml");
SAVED IT HERE: ???
C:\Users\user1\Downloads\Linqpad_SetValueReplacesChidCntent.
xml
36 | P a g e
Linq Bakers Dozen Tips – Kevin Goff
http://www.devx.com/codemag/Article/35390/1763/page/1
Schema Changes
Need to remove changed objects from Diagram
and re-add the Object to have changes picked up in DBML.
Alternative: use batch generation tool: SqlMetal to
Re-Generate code ( limitation – regenerates for all tables in
Database ( no way to limit tables )
+ Linq DBML Gotcha !
When changing the Database Schema ( table changes ),
you must manually update your DBML file.
Remove the old table and drag the table back from the
Server Explorer. BUT, make sure you REFRESH the
Database in the Server Explorer or you will not have the
most recent table changes.
ReportViewer Control ( local version of Report Services Report
Viewer )
Report ( .rdlc )
SubReports
Graphing
DataSources ( static vs dynamic )
37 | P a g e
DataSet
Linq Query
Linq query conversion to DataTable in DataSet
Sample Reports
We provide 3 versions to show DNN Event with a list of RSVPs
and attendance.
The outer query lists the Events and the inner query lists the
RSVP records for the event.
1. ListView Control with Nested ListView ( v3.5)
2. GridView Control with Nested GridView ( v.2.0 )
3. ReportViewer Control with Local Reports using nested
SubReports.
We use Linq queries to bind to each of the UI objects: ListView,
GridView, SSRS Reports/SubReports.
DNN Report using jQuery
jQuery – inject jQuery javascript library into page
MS Ajax
Revisiting TSQL !
How do I get a report of the number of Event Attendees vs
RSVP’s ?
39 | P a g e
SSRS Reporting with the ReportViewer
Design Techniques:
Main Report
List Events and the Attendance Count / RSVP Count
Use + - Collapsible indicator to Show RSVP Details for each
event.
Use SubReports
Graph SubReport
Attendee List Sub Report
SSRS Report Printing – Web Reports
Databinding to Main Report / SubReports using Linq
Reports are normally built using DataSets at design time.
PROBLEM: WebSite DataSources don’t show the Typed DataSets
Workaround: Use a Report Project ( Business Intelliigence VS
2008 / 2005 ? ) to design your report with DataSets.
But you can also supply Linq queries at runtime to populate
the DataSource ( expecting data in the form of the DataSet used
at design time ).
The runtime bindings:
40 | P a g e
An event is fired for each SubReport in your main Report:
xxxx
Query the data using Linq and populate the data source
The ReportViewer supports printing to PDF and Excel.
Watchout: … SubReports don’t print in Excel, but do show in the
Export PDF .