繁体   English   中英

Silverlight linq-to-entities匿名类型问题

[英]Silverlight linq-to-entities Anonymous type problem

我正在尝试使用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数据绑定

他们说我们可以使用匿名类型,但是我该如何将“ as DataServiceQuery ..........?

当安东尼告诉我有关内部异常的信息时。 我在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;
}

谢谢安东尼。 我不知道内部异常存在。

暂无
暂无

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

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