我试了几天却没有成功......
我的课程:
public class ClassA : Entity
{
public virtual IList<ClassB> MyBClassList{ get; set; }
public virtual int MyIntA{ get; set; }
}
public class ClassB : Entity
{
public virtual ClassA MyClassA { get; set; }
public virtual ClassC MyClassC { get; set; }
public virtual double? MyValueB { get; set; }
}
public class ClassC : Entity
{
public virtual double? MyValueC1 { get; set; }
public virtual double? MyValueC2 { get; set; }
}
好的,现在我尝试制作我的DTO查询:
var list = repositoryA.GetAll()
.Select(x => new
{
Id = x.Id,
MyInt = x.MyIntA,
BList = x.MyBClassList.DefaultIfEmpty()
.Select(y =>
{
y.MyValueB,
y.MyClassC.MyValueC1,
y.MyClassC.MyValueC2
}).ToList()
});
Query执行时没有错误,但我得到了BList的重复行,结果很奇怪......
为什么?我做错了什么?
我正在使用NHibernate 4.0.0.2 alpha ...
由于