通过WCF服务公开IQueryable [英] Expose IQueryable Over WCF Service

查看:71
本文介绍了通过WCF服务公开IQueryable的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在学习有关IQueryable和查询的延迟加载/延迟执行.

I've been learning about IQueryable and lazy loading/deferred execution of queries.

是否可以通过WCF公开此功能?我想公开一个LINQ-to-SQL服务,该服务返回一个IQueryable,然后我可以在客户端上执行其他查询,最后使用.ToList()执行.在这种情况下,OData格式是否完全适用?

Is it possible to expose this functionality over WCF? I'd like to expose a LINQ-to-SQL service that returns an IQueryable which I can then perform additional queries on at the client, and finally execute using a .ToList(). Is OData format applicable at all in this context?

如果可能的话,该技术的术语是什么?我可以遵循哪些好的教程?谢谢.

If possible, what is the term for this technique and what are some good tutorials I can follow? Thank you.

推荐答案

您应检查 WCF数据服务,它将允许您在客户端上定义Linq查询. WCF数据服务可能是满足您需求的唯一解决方案.

You should check WCF Data Services which will allow you to define Linq query on the client. WCF Data Services are probably the only solution for your requirement.

IQueryable仍然只是接口,其功能取决于实现接口的类型.您不能直接公开Linq-To-Sql或Linq-To-Entities查询.存在短时间上下文或序列化等多​​种原因将执行查询,因此客户端将获得所有对象的列表,而不是查询.

IQueryable is still only interface and the functionality depends on the type implementing the interface. You can't directly expose Linq-To-Sql or Linq-To-Entities queries. There are multiple reasons like short living contexts or serialization which will execute the query so the client will get list of all objects instead of the query.

这篇关于通过WCF服务公开IQueryable的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆