1

I have a stored procedure which returns the status of databasemail in SQL Server, which return string "stopped" or "started". I must use it in C#, Silverlight and WCF Data Service.

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.

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)." in this duscussion http://go4answers.webhost4life.com/Example/incoking-webget-throws-exception-56000.aspx. Is it true?

4

1 回答 1

0

IQueryable 通常用于尚未执行的列表,并且需要交互式迭代。因为您在服务器上将数据拉到一起,所以最好拉出整个状态记录列表,然后将它们发送给您的客户端。尝试在您的回复中使用 List 而不是 IQueryable。请注意,List 是可序列化的。

假设“CurrentDataSource.status_serwer()”返回一个可枚举的字符串列表,这段代码可能会成功:

[WebGet]
public List<String> Status_Serwer()
{
    return CurrentDataSource
          .status_serwer()
          .ToList();
}
于 2012-08-09T18:33:38.023 回答