Question

Trying to project query result into a list of integers. How does one do that? What transformer should be used. AliasToBean does not work as it requires 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>();
Was it helpful?

Solution

Another way:

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

(get rid of the TransformUsing all together)

OTHER TIPS

That was easy, after looking at the options, PassThrough looked like it would work, and it did.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top