Sunday 15 June 2014

c# - Is there any way of knowing the content of an IQueryable object without using Reflection? -


I have to work with a given class "QueryGenerator" that matches the dynamic queries And by using string connection and provider, the column by the user anyway, I do not need to know the implementation of the class, but I have to use it and I'm in stock.

Finally, "query generator" returns the result of query as an object, the only thing I know (because I use the reflector on the square) Here is an example that I can put an IQueryable on that query result:

  var result = (IQueryable) myQueryGenerator.Result; To know the contents of   

and results , I have to use reflection.

So, is there a better way to know the contents of the results , and, for example, fill a dataset with it?

No, no.

IQueryable can return different types of objects (for example, if you query against an array of objects) in this extreme case you will need to determine the type of each individual item in the enumerated query .

Example code to display this scenario:

  object [] Objs = new object [3] {"string", 78, datetime.now}; Var q = objs.AsQueryable (). Skip (1) Take (2); Forresh (Y in OQ) {var t = o.GetType (); }    

No comments:

Post a Comment