简体   繁体   English

如何通过URI将参数传递给WCF RIA服务查询

[英]How to pass a parameter to WCF RIA Service query through URI

I have a custom WCF RIA Service query that accepts one parameter. 我有一个接受一个参数的自定义WCF RIA服务查询。 I can access the method via URI by calling: 我可以通过调用URI来访问该方法:

/WCF_RIA_ServiceData.svc/GetJobDataByEmployee

but because my query is dependant upon the parameter being passed, nothing is returned. 但是由于我的查询取决于所传递的参数,因此不会返回任何内容。 I have tried to pass the parameter(int) multiple ways: 我试图以多种方式传递parameter(int):

/WCF_RIA_ServiceData.svc/GetJobDataByEmployee(1)
/WCF_RIA_ServiceData.svc/GetJobDataByEmployee/1
/WCF_RIA_ServiceData.svc/1/GetJobDataByEmployee/
/WCF_RIA_ServiceData.svc/GetJobDataByEmployee?EmployeeID=1/
/WCF_RIA_ServiceData.svc/GetJobDataByEmployee?1/

All of which fail. 所有这些都失败了。 Can someone please let me know how to call the method with a parameter? 有人可以让我知道如何使用参数调用该方法吗? Thank you for any info! 感谢您提供任何信息!

I have figured it out. 我已经知道了。

/WCF_RIA_ServiceData.svc/GetJobDataByEmployee?EmployeeID=1/

is the correct way to call it, but you have to specify that it has side-effects by adding this line before your method in the WCF RIA Service. 是调用它的正确方法,但是您必须通过在WCF RIA服务中的方法之前添加此行来指定它具有副作用。

[Query(HasSideEffects = true)]

I don't quite understand why this is required, because in my case the code doesn't actually cause any side-effects. 我不太明白为什么需要这样做,因为在我的情况下,代码实际上并没有引起任何副作用。 If anyone has any information on why this is required please let me know. 如果有人对为什么需要这样做有任何信息,请告诉我。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM