Darren166 wrote:
I am trying to set the entitycollection of a datasource by using
LampSpecCollection LampSpecs = new LampSpecCollection();
IPredicate filter = (LampSpecFields.LampSpecId == 2);
LampSpecs.GetMulti(filter);
LLBLGenProDataSource1.EntityCollection = LampSpecs;
The datasource is tied to a gridview.
I can monitor the SQL and I see that the correct SQL is being applied and filtering on LampSpecId = 2, however straight after that another SQL statement is sent as a SQL:BatchStarting that retrieves the entire table and that is used to fill the gridview.
There is no other code in the project. I am using the Dec 6th final 2.0 build with asp.net 2
Why is the Gridview displaying the entire table instead of just the items with LampSpecId = 2?
Darren
The reason for this is that the grid gets rebound to the datasourcecontrol by asp.net and then asks for data, as the filter isn't set in the datasourcecontrol it simply fetches all data.
So instead of your code above, you should do:
LLBLGenProDataSource1.FilterToUse= new PredicateExpression(LampSpecFields.LampSpecId == 2);
(as Walaa described)
That's it. You set the filter, and when the grid asks for data, the datasourcecontrol will fetch the data requested with the filter you set.