How can I make sure my LINQ queries execute when called in my DAL, not in a delayed fashion?
-
06-07-2019 - |
Question
I have a DAL that is composed of a bunch of methods that perform LINQ queries on my database.
How do I ensure that before returning say an IEnumberable or something similar from the database, I ensure that the LINQ query is execute then, not in some delayed fashion only to be executed when the result is used?
I know I can call .ToList() on my result in my methods to force it to execute, but is this the best way?
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow