[英]WCF data service custom implementation
How to pass parameters from client to method in server in order to get entity data. 如何从客户端向服务器中的方法传递参数以获取实体数据。
At Server side : 在服务器端:
List<Foo> getFoos = _serverObject.GetFoos(p1, p2); //Here's how I am getting foo from another server
class FooProvider
{
public IQueryable<Foo> Foos
{
get{return getFoos.AsQueryable();}
}
}
At Client Side : 在客户端:
var res = from f in ctx.Foos
where f.p1 == p1_val && f.p2 == p2_val
select f;
Now what I am trying to get is all Foo record depend on p1_val
and p2_val
parameters, but I would have to pass it to _serverObject.GetFoos(p1, p2)
; 现在我要获取的是所有Foo记录都取决于
p1_val
和p2_val
参数,但是我必须将其传递给_serverObject.GetFoos(p1, p2)
; so that the p1
and p2
are set from client not from the server. 因此
p1
和p2
是从客户端而不是从服务器设置的。
Please suggest some mechanism 请提出一些机制
I do believe what you try to achieve is mostly related to 我确实相信您尝试实现的目标与
Using an ADO.NET Entity Framework DataSource(WCF Data Services) 使用ADO.NET实体框架数据源(WCF数据服务)
and passing a parameter from client to server is only the tip of the iceberg however if I am wrong and all your problems will be resolved by only passing complex types p1, and p2 from client to server then do the following: 并将参数从客户端传递到服务器只是冰山一角,但是,如果我错了,并且仅通过将复杂类型p1和p2从客户端传递到服务器即可解决所有问题,那么请执行以下操作:
Moral of the story: You need to define those two types in your service as Data Contracts so you can use them as parameter in your proxy class on the client side. 故事的寓意:您需要在服务中将这两种类型定义为数据合同,以便可以将它们用作客户端代理类中的参数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.