Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Crystal Reports and LINQ

Has anyone figured out how to use Crystal Reports with Linq to SQL?

like image 242
David Vidmar Avatar asked Sep 18 '08 22:09

David Vidmar


People also ask

Is Crystal Reports still popular?

Anyone that uses Crystal Reports or Crystal Server is bound to have a lengthy list of grievances. The product has an extremely high market share and continues to hold on to that market share, despite its limitations (a whopping 68% still). This is because Crystal Reports will get the job done.

Does Microsoft own Crystal Reports?

Crystal Reports is a popular Windows-based report writer solution that allows a developer to create reports and dashboards from a variety of data sources with a minimum of code to write. Crystal Reports is owned and developed by SAP.

Is Crystal Reports a data visualization tool?

Crystal Reports can power pixel-perfect reporting for businesses. This solution enables organizations to combine analysis, business intelligence and decision support based on their data. The tool can analyze multiple data sources and then create visualizations of the data in charts and tables.

What database does Crystal Reports use?

When you connect to an SQL database, Crystal Reports acts as an SQL client application, connecting to your SQL server through your network. When you design a report that accesses SQL data, Crystal Reports builds an SQL query. This query can be seen by choosing Show SQL Query from the Database menu.


2 Answers

You can convert your LINQ result set to a List, you need not strictly use a DataSet as the reports SetDataSource, you can supply a Crystal Reports data with an IEnumerable. Since List inherits from IEnumerable you can set your reports' Data Source to a List, you just have to call the .ToList() method on your LINQ result set. Basically:

        CrystalReport1 cr1 = new CrystalReport1();

        var results = (from obj in context.tSamples
                      where obj.ID == 112
                      select new { obj.Name, obj.Model, obj.Producer }).ToList();

        cr1.SetDataSource(results);
        crystalReportsViewer1.ReportSource = cr1;
like image 179
Mohammad Sepahvand Avatar answered Sep 17 '22 14:09

Mohammad Sepahvand


The msdn doc's suggest that you can bind a Crystal Report to an ICollection.

Might I recommend a List(T) ?

like image 37
Amy B Avatar answered Sep 17 '22 14:09

Amy B