Page 1 of 1

Report from DbSet BusinessObjects

Posted: Thu Oct 24, 2013 7:58 am
by Vrokolos
I'm trying to bind a report directly to a dbset but Entity Framework is not allowing me to do so.
What I would like to achieve is to provide all my EF dbsets as business objects in a report and then do all the filtering and quering using report filters / variables when needed so that the underlying SQL queries get built from the report.

The problem is that EF will not allow data-binding directly to dbset without calling ToList() or Local first

Here is why: http://stackoverflow.com/a/13909122

This answer is quite logical when using data bound to user-interactive controls like editboxes and comboboxes.
In a report however this answer doesn't make sense since most data is read-only and there won't be any user interaction that alters the query after the report is rendered.

Do you know of any workarounds for my problem?

Re: Report from DbSet BusinessObjects

Posted: Fri Oct 25, 2013 6:24 am
by Alex K.
Hello,

Sorry, maybe we did not exactly understand your problem. Could you explain your issue in more details?

Thank you.

Re: Report from DbSet BusinessObjects

Posted: Fri Oct 25, 2013 6:50 am
by Vrokolos
I'm registering my EF5 Code First DbSets as Business Objects in a stimulsoft report and then use them in it
On report.Render(); I get an exception:

Code: Select all

Data binding directly to a store query (DbSet, DbQuery, DbSqlQuery) is not supported. Instead populate a DbSet with data, for example by calling Load on the DbSet, and then bind to local data. For WPF bind to DbSet.Local. For WinForms bind to DbSet.Local.ToBindingList().
If I pass DbSet.ToList() as the business object instead of my actual DbSet then everything works fine but I don't want to do that

Re: Report from DbSet BusinessObjects

Posted: Fri Oct 25, 2013 11:42 am
by Alex K.
Hello,

This exception is Entity Framework, not our. Please use the DbSet.ToList() for passing.

Thank you.

Re: Report from DbSet BusinessObjects

Posted: Fri Oct 25, 2013 2:02 pm
by Vrokolos
If I use dbset.ToList() my whole table (3.000.000 records) will get retrieved locally and passed to the report.

So I need to perform all my filtering manually before the report gets rendered.

You can't find any workaround for this so that the report filters get applied to the IQueryable?

Probably a parameter to call ToList() yourself after all the filters get applied and before rendering the report?

Re: Report from DbSet BusinessObjects

Posted: Mon Oct 28, 2013 12:32 pm
by Alex K.
Hello,

For SQL queries we have the option (FilterEngine=SQLQuery), which allows you to convert the conditions in a query for filtering. But for the business objects it is very hard to implement and a time-consuming task. So we do not even have plans to implement it. Please filter the data before rendering the report.

Thank you.

Re: Report from DbSet BusinessObjects

Posted: Wed Jan 22, 2014 2:31 pm
by Vrokolos
But why create your own logic for filtering business objects when I can use Linq to filter those and let entity framework automatically transform the linq into SQL by the entity framework?

In other words you should implement better entity framework integration. There's no point in integrating entity framework if I'm going to run SQL queries to bring and filter the data on the reporting engine. You should support linq to entities!

Re: Report from DbSet BusinessObjects

Posted: Thu Jan 23, 2014 6:41 am
by Alex K.
Hello,

It is very hard to implement and a time-consuming task. So we do not even have plans to implement it. Please filter the data before rendering the report.

Sorry.