我的 DTO:
public class ServiceWithCount
{
public Service Service { get; set; }
public long Count { get; set; }
}
和:
public class Service
{
public virtual long Id { get; set; }
...
}
public class Vote
{
public virtual long Id { get; set; }
public virtual Service Service { get; set; }
...
}
我想做类似的事情:
ServiceWithCount dto = null;
Service serviceAlias = null;
var result = session.QueryOver<Service>(() => serviceAlias)
.Where(x => x.Serie.Id == serie.Id)
.SelectList(list =>
list
.SelectSubQuery(QueryOver.Of<Vote>().Where(y => y.Service.Id == serviceAlias.Id).ToRowCountInt64Query()).WithAlias(() => dto.Count)
.Select(x => x).WithAlias(() => dto.Service) //This line causes error
)
.TransformUsing(Transformers.AliasToBean<ServiceWithCount>())
.List<ServiceWithCount>();
但这会导致错误:
could not resolve property: of: MyNamespace.Service
如何将根类型对象作为 dto 的组件返回?