开发者

LINQ Provider to RESTful service

开发者 https://www.devze.com 2023-01-05 08:39 出处:网络
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 retu

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.


Hi you should check out my project LinqToAnything which makes it dead easy to do exactly that.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消