Tuesday, 10 September 2013

LINQ TO Entities: Handling Includes

LINQ TO Entities: Handling Includes

probably you have a solution. First of all its just a thought of mine, but
I guess we will run in some problems in the future: We have a
businessfacade, which handles the context call with an filter expression,
let's say this:
List<INDIVIDUAL>
IIndividual.GetIndividuals(Expression<Func<INDIVIDUAL, bool>>
filterExpression)
{
List<INDIVIDUAL> result = null;
this.FacadeAction(ctx =>
{
result = (filterExpression != null
? ctx.INDIVIDUALs.Where(filterExpression)
: ctx.INDIVIDUALs).ToList();
result.StartTracking();
});
return result;
}
Nothing to special: if there is a expression, get all individuals with
this filter, otherwise return all. The problem now: I wanna include
another table for ONE case. So my thoughts: There should be an optional
parameter, which I can add tables I wanna include with. So I dont need x
functions for the same entitiyset but can dynamically add all the tables I
want to include.
Do you think something like this is possible? Does this even makes sense?
Or is it better to call the facade for each entitiy I need?
Thanks for your response!
Matthias Müller

No comments:

Post a Comment