lundi 4 juillet 2016

Check IQueryable

I am writing a Pager so that all my Queries (either DB or List Based) can use the same logic.

this seems to work correctly for functions like StartsWith when the data type is a System.Collections.Generic.List<T> but when the query comes from a DB Store (EF) it complains as i am setting the StringComparison property (EF does not implement the method signature with StringComparision)

What I have done is write 2 seperate functions 1 for normal list (with StringComparison and one for a DB Connected Query

My Question is: What is the best way to see if the Query is from a Data Store (without actually referencing the EF Modules as i dont want to be tied to EF).

This is what i currently have that works:

bool _queryConnectedToData=query.Provider.GetType().Namespace.ToLower().Contains("system.data");





Aucun commentaire:

Enregistrer un commentaire