views:

28

answers:

1

I'm writing a custom LINQ provider to a RESTful service. Some of the calls in the service return summary headers, including total number of records, pagesize, and the page of the return. I need clean a way to return this data. Given this query:

var foo = from x in ctx.MyQueryableThingie
          select x;

The "foo" variable above becomes an IQueryable<MyQueryableThingie>. What is the best way to return those summary data without attaching it to each member of the collection? I've considered making them properties of the Context, such the properties would be updated with each query, but I'm not sure that's the best pattern.

A: 

I'd say store it in a queryProvider. that Way You will ensure that each instance has the properties from the query executed by that instance (which would be difficult when dealing with static fields). Of course from a syntactical point of View, this information is a part of the QueryResult, so You could go for some additional effort and implement a

IMyCustomQueryResult<T> : IEnumarable<T>

but that would probably make it too much fuss, Queryprovider is probably the best way to store it, because it is the query provider who does the parsing, and execution, so That might be the place for storing the info (and it is obtainable from the IQueryable anyway) But that is just my thoughts. Good luck with implementation anyway. Cheers luke

luckyluke