在客户端应用程序中使用 WCF 数据服务引发错误 [英] Consume WCF Data service in client application throws error
问题描述
我正在研究导入存储过程的 WCF 数据服务,如下所示.
I am working on WCF Data service which imported stored procedure, as below.
[WebGet]
public List<GetMTSearchResultTest_Result> GettMTSearchResultTest()
{
MediaMarketResearch_PRODEntities ent = new MediaMarketResearch_PRODEntities();
return ent.GetMTSearchResultTest().ToList();
}
当我在客户端应用程序中使用它时,它显示错误为封闭类型 MMRClient.MMRServiceReference.GetMTSearchResultTest_Result 没有相应的元素可设置属性."
when i consuming this in my client application it says error as "The closed type MMRClient.MMRServiceReference.GetMTSearchResultTest_Result does not have a corresponding element settable property."
绑定到网格视图时出现此错误,如下所示.
I am getting this error while bind to the grid view as below.
DataServiceContext context = new DataServiceContext(new Uri("http://localhost:4131/MMRDataService.svc/"));
IEnumerable<GetMTSearchResultTest_Result> empResult = context.Execute<GetMTSearchResultTest_Result>(new Uri("http://localhost:4131/MMRDataService.svc/GettMTSearchResultTest"));
GridView1.DataSource = empResult;
GridView1.DataBind();
注意:我将此存储过程导入为复杂类型.
Note: I imported this stored proc as complex type.
请就此给我建议.
问候,
杰迪普
推荐答案
您始终可以对非数据服务进行新的服务引用.那就是正常的 WCF 服务.你可以简单地让 [ContractOperation] 返回一个有问题的复杂类型"的列表,就是这样.
You can always make a new service reference to a non data service. That is to a normal WCF service. You can simply have a [ContractOperation] returning a list of the troubled "complex types" and that's it.
这样,您将拥有两个服务,原始数据服务和新的普通 WCF 服务.但这不应该是这样的问题.您不必将陷入困境的复杂类型"作为实体.
This way you would have two services the original data service and a new normal WCF service. But this shouldn't be such an issue. You don't have to make the troubled "complex type" as a Entity.
这篇关于在客户端应用程序中使用 WCF 数据服务引发错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!