简体   繁体   English

WCF和错误存储过程

[英]WCF and error stored procedure

I have a stored procedure which returns the status of databasemail in SQL Server, which return string "stopped" or "started". 我有一个存储过程,该存储过程在SQL Server中返回databasemail的状态,并返回字符串“ stopped”或“ started”。 I must use it in C#, Silverlight and WCF Data Service. 我必须在C#,Silverlight和WCF数据服务中使用它。

Here's my code: 这是我的代码:

contex.BeginExecute<String>(new Uri(uri2), OnQueryComplete3, null);
...
private void OnQueryComplete3(IAsyncResult result)
{
   grLog.ItemsSource = contex.EndExecute<String>(result).ToList<String>();
}

And I have error: 我有错误:

Error processing response stream. 处理响应流时出错。 The XML element contains mixed content. XML元素包含混合内容。

The service operation: 服务操作:

[WebGet]
public IQueryable<String> Status_Serwer()
{
return CurrentDataSource
.status_serwer()
.AsQueryable();
}

I find ".NET 4.0 still doesn't support materialization of responses from service operations returning primitive or complex types (or collections of those)." 我发现“ .NET 4.0仍然不支持返回原始或复杂类型(或这些类型的集合)的服务操作的响应的实现。” in this duscussion http://go4answers.webhost4life.com/Example/incoking-webget-throws-exception-56000.aspx . 在本文中http://go4answers.webhost4life.com/Example/incoking-webget-throws-exception-56000.aspx中 Is it true? 是真的吗

IQueryable is normaly used for a list that hasn't been executed yet, and requires interactive iteration. IQueryable通常用于尚未执行的列表,并且需要交互式迭代。 Because you are pulling your data together on the server it may be better to pull the entire list of status records and then send them to your client. 因为您是在服务器上将数据汇总在一起,所以最好提取整个状态记录列表,然后将其发送给客户端。 Try using a List instead of IQueryable in your response. 尝试在响应中使用列表而不是IQueryable。 Note that List is serializable. 请注意,列表是可序列化的。

Assuming that "CurrentDataSource.status_serwer()" returns an enumerable list of strings, this code might do the trick: 假设“ CurrentDataSource.status_serwer()”返回一个可枚举的字符串列表,则此代码可以解决问题:

[WebGet]
public List<String> Status_Serwer()
{
    return CurrentDataSource
          .status_serwer()
          .ToList();
}

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

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