Skip to Content
Author's profile photo Trevor Dubinsky

Using LINQ with the Crystal Reports SDKs

 from ReportObject crRptObj in rptDoc.ReportDefinition.ReportObjects


This declares the variable crRptObj as type ReportObject, then it says to search or iterate through the collection rptDoc.ReportDefinition.ReportObjects assigning it to the crRptObj variable.


where crRptObj.Kind == ReportObjectKind.SubreportObject


This is the comparison statement, it allows you to select the conditions to look for.

Like an SQL query you can set multiple conditions through the use of AND, OR, NOT statements.


 select (SubreportObject)crRptObj;


If the WHERE statement condition is met, then this line adds a variable to the result set. This could be the current item in the collection, or a completely different object. In this case we are type-casting the current object into a SubreportObject and returning that. 

The result has to match  the type that we defined QueryResults in the first item.


 I hope this was useful or at least a little interesting and that you will try to incorporate LINQ into your code!

Here are some websites on LINQ:

And the LINQ to my Crystal Add-In sample, though it has not been updated yet with the LINQ code:


Assigned Tags

      Be the first to leave a comment
      You must be Logged on to comment or reply to a post.