generics - Best way to pass Entity Framework entity collections from the DAL to the Business Layer? -
I have a DAL that calls my entity framework model. The call sends back things like IOrderedQueryable and IQueryable objects. Should I change them in my DAL more universally, such as the list? But I think that if I do not need to calculate through the entire collection, then it can be useless ... so what's the best way? Just backed DAL to IQueryable & lt;> and when I need it, can I change it? Or is something more flexible? Thanks in advance.
I have only one question, but I'm not sure what the correct answer is. I think DAL is back to IQueryable & lt;> really the most flexible, because you can easily execute another LINQ query at the top of it (if necessary) on the second layer of code.
The idea is that when returning an IQueryable, the results are not yet loaded into memory. So returning is actually the LINQ "query". Therefore, this is a slightly different behavior that people can be used, which happens when something is withdrawn from the model, it is actually the result from the database.
In my case, we are returning the list from our DAL to IQueryable & lt;>. By calling ToList ()), if this list needs to be filtered, then we make another DAL method which instead returns a filtered list. We chose this because the second layer calling DAL is not necessary to know that we are using the unit framework in this way (no dependencies).
Comments
Post a Comment