Page 1 of 1

LINQ in Report

Posted: Mon Sep 03, 2012 11:53 am
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.

Re: LINQ in Report

Posted: Mon Sep 03, 2012 12:52 pm
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.

Re: LINQ in Report

Posted: Tue Sep 04, 2012 7:13 am
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.

Re: LINQ in Report

Posted: Wed Sep 05, 2012 7:40 am
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.