我正在尝试使用silverlight,wcf数据服务(在网站代码上)和Linq- to -Entities。我知道匿名类型在silverlight上不起作用,于是我创建了一个已知的类来检索一些信息。(我知道它的查询并不完全智能,但它只是一个示例),但它不起作用。谁能帮帮我?
这就是代码。
public class DataSummary
{
public DataSummary() { }
public int AccountID { get; set; }
public string Account { get; set; }
int accountID;
string account;
}
var p = (from q in svc.Accounts
select new DataSummary()
{ AccountID = (int) q.AccountID,
Account = q.Account1
}) as DataServiceQuery<DataSummary>;
p.BeginExecute(new AsyncCallback(r =>
{
try
{
this.grid.ItemsSource = p.EndExecute(r).ToList();
}
catch (Exception ex)
{
string message = ex.Message;
}
}), null);当我运行这个示例时,错误消息是
ex.Message "An error occurred while processing this request." string这很有趣,因为它没有解释这个问题。
同样在这个问题中
Silverlight 4 Data Binding with anonymous types
他们说我们可以使用匿名类型,但是我怎么才能把"as DataServiceQuery..........?“
发布于 2010-07-07 02:34:10
当安东尼告诉我内心的异常时。我在ProtocolVersion上发现了这个错误。
public static void InitializeService(DataServiceConfiguration config)
{
config.SetEntitySetAccessRule("*", EntitySetRights.All);
//On the service. You have to add this line
config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2;
}谢谢安东尼。我不知道内部异常的存在。
https://stackoverflow.com/questions/3187315
复制相似问题