LINQ in Report

Stimulsoft Reports.WPF discussion
Post Reply
Niqu
Posts: 81
Joined: Wed Aug 08, 2012 9:08 am

LINQ in Report

Post by Niqu »

Hello.

I am wondering is it possible to use Linq in Report?
For example using Linq query in TextField to display data: .Where(x => x.Id == 2).First() or something like that.

In my report I have business object that contains some field. One of this fields is Id_a. I have also list of object with fields: Name, Id_b. I want to display Name if Id_b == Id_a.
In C# this code look something like this:
var tmp = object_a.Where(x => x.Id == object_b.Id).FirstOrDefault();
string name = tmp != null ? tmp.Name : string.Empty;
Is it possible to do something like that in report?
I added "using System.Linq" in code, but when i was trying to use "Where" query i got error that business object does not contain defintion for "Where".
Perhaps I am doing something wrong and I should add this query in other place, but I am not sure where.

If you have trouble with understand what I want to achive, I can try make some project to show it.

Thank you in advance.
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: LINQ in Report

Post by Alex K. »

Hello,

Please see the sample projects in attachment.
If it is does not help, please send us your sample project with detail describe.

Thank you.
Attachments
LinqToSql.Net.zip
(24.95 KiB) Downloaded 326 times
Linq.zip
(14.52 KiB) Downloaded 318 times
Niqu
Posts: 81
Joined: Wed Aug 08, 2012 9:08 am

Re: LINQ in Report

Post by Niqu »

I saw this two sample, but I couldn't find there what I need.
I add two attachment: empty report and project to fill date in this report (in project is report, I just add two attachment because maybe only report will be enough for you).
In this report I have two business object: list of parents (each parent has children - list of child) and a child.
I want to display grid with two columns: parent name and name of parent child whose id is the same as id of business object child.
For me the best option would be using Linq in report to do it, but I am not sure that it is possible and if it is I don't have much idea how to do it.

If something is unclear, I can try to explain it more.

Thank you in advance.
Attachments
Report.mrt
(8.41 KiB) Downloaded 302 times
StimulsoftWpfApplication.zip
(1.67 MiB) Downloaded 283 times
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: LINQ in Report

Post by Alex K. »

Hello,

Unfortunately, but it is not possible to use linq queries as expressions in text components. As a way, in your case, you can use the filters and master-details constructions in reports.

Thank you.
Attachments
Report_modified.mrt
(8.94 KiB) Downloaded 402 times
Post Reply