通过SelectList创建投影时,是否可以将组件转换为dto。
我有一个值对象Name,我需要将它投影到Dto NameInfo中。以下是查询。 我需要在这一行上迈出一步
.Select(c=> coveredInsured.Name).WithAlias(()=>info.Name)
一些事情
.Select(c => new NameInfo { Last= c.Last, First=c.First, Middle = c.Middle}).WithAlias(()=>info.Name)
这是失败的实际查询,因为它无法将Name转换为NameInfo。所以。除了在我的dto上暴露三个属性之外,还有一种投射方式吗?
.SelectList(list => list
.Select(c => c.Id).WithAlias(() => info.CoverageId)
.Select(c => bid.Year).WithAlias(() => info.PolicyYear)
.Select(c => bid.OptionNumber).WithAlias(() => info.OptionNumber)
.Select(c=> ((ClientBase)client).Number).WithAlias(()=>info.ClientNumber)
.Select(c => c.PrimaryInsured.Id).WithAlias(() => info.PrimaryInsuredId)
.Select(c => c.CoveredInsured.Id).WithAlias(() => info.CoveredInsuredId)
.Select(c=> coveredInsured.Name).WithAlias(()=>info.Name)
)
.TransformUsing(Transformers.AliasToBean<InsuredCoverageInfo>())
.List<InsuredCoverageInfo>()
.ToList();