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

查看:35
本文介绍了通过 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天全站免登陆