linq - Force an IQueryable to execute? -
I have a method that has no translation in SQL, which I want to execute on an IQueryable Is there some way to store it in Intermediate class to compel IQueryable?
What is the problem that you want your method to perform locally instead of the database? If so, then unlimited is your friend. This is a very simple method, such as something:
public INMImable & lt; T & gt; AsEnumerable (IEnumerable & lt; T & gt; Source) {Return Source; } The important thing is that this compil-time type result is returned by IEnumerable < T & gt; Instead of IQueryable & lt; T & gt; , which means that you will call LINQ query operators after LINQ with an object rather than SQL, from LINQ.
For example:
var query = context employee // display filtering in SQL Where (emp = & gt; emp.IsFullTime) ASANMERABLE () // launch was done locally; There is no // SQL equivalent in ComputeSalary. Select (emp = & gt; new {employee = amp, salary = computational (amp}}); You can call anywhere on the toList , but if you are filtering and actually complete The list is not needed Memory, asenumerable calling and filtering that result will be more efficient than loading everything first.
Comments
Post a Comment