我有一个带有 Group 类型 ObservableCollection 的 MainBusinessLine 类型,我从 DomainService 调用的方法返回 MainBusinessLines 的可查询列表。因此,在此方法中,我已确认所有适当的组都已添加到 MainBusinessLines 组集合中。但是,当实体加载到客户端 silverlight 应用程序中时,几乎所有实体都丢失了。但更重要的是 MainBusinessLine 有另一个集合,它确实包含客户端加载操作后的所有适当实体。而我的 Association Attributes 也是一样的,也就是说 thisKey 和 otherKey 的参数设置类似。
我也在创建 POCO 类,而不是使用 EntityFramework。这是我的 MainBusinessLine 类的示例:
[Serializable,
DataContract]
public class MainBusinessLine : BaseDataContract
{
public MainBusinessLine()
{
}
private int _MainBusinessLineID;
[Key,
DataMember,
Required]
public int MainBusinessLineID
{
get
{
return _MainBusinessLineID;
}
set
{
if (_MainBusinessLineID == value)
return;
ReportPropertyChanging("MainBusinessLineID");
_MainBusinessLineID = value;
ReportPropertyChanged("MainBusinessLineID");
}
}
private ObservableCollection<LOBs> _DefaultLOBs;
[DataMember,
XmlIgnore,
SoapIgnore,
Include,
Association("DefaultLOBsCollection", "MainBusinessLineID", "MainBusinessLineID")]
public ObservableCollection<LOBs> DefaultLOBs
{
get
{
return _DefaultLOBs;
}
set
{
ReportPropertyChanging("DefaultLOBs");
_DefaultLOBs = value;
ReportPropertyChanged("DefaultLOBs");
}
}
private ObservableCollection<Groups> _Groups;
[DataMember,
Include,
Association("GroupsCollection", "MainBusinessLineID", "MainBusinessLineID")]
public ObservableCollection<Groups> Groups
{
get
{
return _Groups;
}
set
{
ReportPropertyChanging("Groups");
_Groups = value;
ReportPropertyChanged("Groups");
}
}
}
这里是 LOBs 和 Groups 类:
[Serializable,
DataContract]
public class LOBs : BaseDataContract
{
private int _LOBID;
[Key,
DataMember,
Required]
public int LOBID
{
get
{
return _LOBID;
}
set
{
if (_LOBID == value)
return;
ReportPropertyChanging("LOBID");
_LOBID = value;
ReportPropertyChanged("LOBID");
}
}
private int _GroupID;
[DataMember]
public int GroupID
{
get
{
return _GroupID;
}
set
{
if (_GroupID == value)
return;
ReportPropertyChanging("GroupID");
_GroupID = value;
ReportPropertyChanged("GroupID");
}
}
private int _MainBusinessLineID;
[DataMember]
public int MainBusinessLineID
{
get
{
return _MainBusinessLineID;
}
set
{
if (_MainBusinessLineID == value)
return;
ReportPropertyChanging("MainBusinessLineID");
_MainBusinessLineID = value;
ReportPropertyChanged("MainBusinessLineID");
}
}
}
[Serializable,
DataContract]
public class Groups : BaseDataContract
{
private int _GroupID;
[Key,
DataMember,
Required]
public int GroupID
{
get
{
return _GroupID;
}
set
{
if (_GroupID == value)
return;
ReportPropertyChanging("GroupID");
_GroupID = value;
ReportPropertyChanged("GroupID");
}
}
private int _MainBusinessLineID;
[DataMember]
public int MainBusinessLineID
{
get
{
return _MainBusinessLineID;
}
set
{
if (_MainBusinessLineID == value)
return;
ReportPropertyChanging("MainBusinessLineID");
_MainBusinessLineID = value;
ReportPropertyChanged("MainBusinessLineID");
}
}
}
有人可以告诉我我在这里可能有什么问题吗?我觉得这与我设置关联属性的方式有关。谢谢