尝试将查询结果投影到整数列表中。怎么做到这一点?应该使用什么变压器。 AliasToBean不起作用,因为它需要setter。
var accessFeeYears = _session.QueryOver<AgreementAccessFee>()
.JoinAlias(a => a.FeeType, () => agreementAccessFeeTypeAlias)
.Where(x => x.Agreement.Id == request.AgreementId
&& agreementAccessFeeTypeAlias.Code ==AgreementAccessFeeTypeCode.FlatChargePerInsured)
.SelectList(list => list
.Select(a => a.PolicyYear).WithAlias(() =>policyYear))
.TransformUsing(Transformers.??????)
.List<int>();
答案 0 :(得分:2)
另一种方式:
_session.QueryOver<AgreementAccessFee>()
.JoinAlias(a => a.FeeType, () => agreementAccessFeeTypeAlias)
.Where(x => x.Agreement.Id == request.AgreementId
&& agreementAccessFeeTypeAlias.Code == AgreementAccessFeeTypeCode.FlatChargePerInsured)
.SelectList(list => list
.Select(a => a.PolicyYear))
.List<int>();
(一起摆脱TransformUsing
)
答案 1 :(得分:0)
这很容易,看完选项后,PassThrough看起来会起作用,而且确实如此。