【发布时间】:2011-03-25 03:53:59
【问题描述】:
我有一个名为StatusUpdates 的实体。它没有自我加入。但是我想包括一个StatusUpdates 类型的 InternalStatusUpdates 列表(我再次提到数据库中没有自加入)。所以我在同一个命名空间中创建了一个部分类,并创建了一个名为 InternalStatusUpdates 的属性,并在其上包含了[DataMember] 属性。但它仍然没有出现在客户端上。这是我要具体说明的部分课程:-
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Objects.DataClasses;
using System.Runtime.Serialization;
using System.ServiceModel.DomainServices.Server;
using System.ComponentModel.DataAnnotations;
namespace FMT.Data.Web
{
public partial class StatusUpdate : EntityObject
{
private List<StatusUpdate> _internalListStatusUpdates = new List<StatusUpdate>();
[DataMember]
public List<StatusUpdate> InternalListStatusUpdates
{
get { return _internalListStatusUpdates; }
set {
_internalListStatusUpdates = value;
OnPropertyChanged("InternalListStatusUpdates");
}
}
}
}
有趣的是,如果我将List<StatusUpdate> 更改为List<string>,它可以在客户端上使用!我该如何解决这个问题?
我想因为它是实体类型,所以我必须指定[Include]。当我这样做时,我收到以下错误:-
Invalid Include specification for member 'StatusUpdate.InternalListStatusUpdates'. Non-projection includes can only be specified on members with the AssociationAttribute applied.
然后我继续指定关联,所以现在我的属性看起来像:-
private List<StatusUpdate> _internalListStatusUpdates = new List<StatusUpdate>();
[DataMember]
[Include]
[Association("internalUpdates", "StatusUpdatesId", "StatusUpdatesId")]
public List<StatusUpdate> InternalListStatusUpdates
{
get { return _internalListStatusUpdates; }
set {
_internalListStatusUpdates = value;
OnPropertyChanged("InternalListStatusUpdates");
}
}
其中StatusUpdatesId 是我在StatusUpdates 实体中的主键,internalUpdates 只是选择的任意名称。现在构建成功并且该属性在客户端上可用,但我从服务器填充的数据在客户端上不可用。如何解决?
提前致谢:)
【问题讨论】:
-
您能与您的 ria 服务的主体共享一个代码 sn-p 吗?
标签: silverlight silverlight-4.0 silverlight-3.0 wcf-ria-services