Query and method calls using the specified method.
Generally, a query object that implements IQueryable <T> is required when you use linq to query.
public class DataA<T> : IQueryable<T> {....}
Then pass
var q = from c in new DataA<int>() where c > 0 select new { a = c.ToString() };
Query, and use IQueryProvider to collect user input expressions for processing.
However, the query itself is only concerned with the availability of linqmethod (Select, Where...) on the query object .....).
Define a generic object as follows:
public class Data<T> { public Data<TResult> Select< TResult>( Expression<Func<T, TResult>> selector) { return new Data<TResult>(); } public Data<T> Where ( Expression<Func<T,bool>> f) { return this; } }
You only need to ensure that the Data has the same instance method as the linq method, (Select, Where ...),
We can still use the same linq syntax for queries:
var q = from c in new Data<int>() where c > 0 select new { a = c.ToString() };
Conclusion: The linq query syntax is irrelevant to the type of the query object. It only checks whether the query object has the same name and method signature (instance method or extension method ).
IQueryable and IQueryProvider are not required in the linq query.
By the way, I personally think that it is best not to use IQueryable in orm, which may easily cause method pollution, and the syntax of the linq query is fixed and cannot be expanded or restricted.
It is better to use various query methods directly in Orm to make it more flexible.