给定这张表
TABLE A(
IdA NUMERIC PRIMARY KEY
,DescA VARCHAR2(200)
)
TABLE B(
IdB NUMERIC PRIMARY KEY
,IdA NUMERIC
,DescB VARCHAR2(200)
)
我要选择
IdA
, DescA
, Count Of B For Each A
进入自定义 DTO
is dto 的投影不是问题,但我正在寻找一种将计数添加到我的查询的方法
A AAlias = null;
DtoType myDTO = null;
return _session.QueryOver<A>(() => AAlias )
.Select(Projections.Property(() => AAlias.IdA).WithAlias(() => myDTO.IdA),
Projections.Property(() => corsoAlias.DescA).WithAlias(() => myDTO.DescA))
.TransformUsing(Transformers.AliasToBean<DtoType>())
.List<DtoType>()
.AsEnumerable();
编辑:域对象:
public class TableA
{
public Guid Id { get; set; }
public string Desc { get; set; }
public ICollection<B> Bs { get; set; }
}
public class TableB
{
public Guid Id { get; set; }
public string Desc { get; set; }
}