0

嘗試將查詢結果投影到整數列表中。如何做到這一點?應該使用什麼變壓器。 AliasToBean無法正常工作,因爲它需要setter。NHibernate預測:如何將QueryOver投影到int列表中?

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>(); 

回答

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一起的)

0

這很容易,看過選項後,PassThrough看起來像會起作用,而且確實如此。