0
上面是代碼,我用它來處理數據從我的域到dto模型,我用於wcf序列化。我的問題是如何將帶有兒童收藏的對象母親傳遞給MotherDTO。在當前的代碼情況下,我只傳遞沒有收集孩子的數據。我是否需要使用會話並添加會話MotherDTO dto = new MotherDTO(數據,會話);並利用該會議來收集dto中的兒童收集情況。如果是這樣,怎麼樣?請幫忙。傳遞對象與域從集合到modelDTO與nhibernate
問候,
public MotherDTO GetMotherData()
{
using (ISession session = instance.OpenSession())
{
using (ITransaction tx = session.BeginTransaction())
{
Mother data = session.Query<Mother>()
.Fetch(x => x.Childrens)
.FirstOrDefault();
tx.Commit();
MotherDTO dto = new MotherDTO(data);
return dto;
}
}
}
MotherDTO.cs
public MotherDTO(Mother x)
{
Name = x.Name;
List<Children>Childrens= new List<Children>();
foreach (Children obj in x.Childrens)
{
States.Add(obj);
}
}
Mother.cs
public virtual string Name
{
get { return _Name; }
set
{
_Name = value;
}
}
public virtual Iesi.Collections.Generic.ISet<Children> Childrens
{
get
{
return _Childrens;
}
set
{
if (_Childrens == value)
return;
_Childrens = value;
}
}
任何人......? – user1084557 2012-02-19 17:52:39