0

当我构建要由 WCF RIA 服务返回给 silverlight 的模型时,silverlight 客户端中不会显示列表属性。

班级:

public class Batch
{
    [DataMember]
    public DateTime Time { get; set; }

    [DataMember]
    public List<BasicInfoModel> Accepted { get; set; }

    [DataMember]
    public List<BasicInfoModel> UnAccepted { get; set; }
}

public class Batch
{
    [Key]
    [DataMember]
    public int Id { get; set; }

    [DataMember]
    public string Name { get; set; }
}

在客户端时,似乎没有生成列表,例如,这是我加载的回调事件:

private void Callback(LoadOperation<Batch> loadOperation)
{
     //there is no such property as `Accepted`
     var acceptedList = loadOperation.Entities.FirstOrDefault().Accepted;
}

难道我做错了什么?

4

1 回答 1

0

我想,你错过了 DataContract 属性,例如

[DataContract]
public class Batch
{
    [DataMember]
    public DateTime Time { get; set; }

    [DataMember]
    public List<BasicInfoModel> Accepted { get; set; }

    [DataMember]
    public List<BasicInfoModel> UnAccepted { get; set; }
}

http://msdn.microsoft.com/en-us/library/ms733127.aspx

于 2012-06-11T19:09:31.723 回答