Get NHibernate QueryOver .SelectList(x) from Function
c#, fluent-nhibernate, nhibernate
Solution
Something like
Func<QueryOverProjectionBuilder<InvoiceDto>, QueryOverProjectionBuilder<InvoiceDto>> GetList()
{
InvoiceDto dto = null;
return list => list.Select(w => w.Client).WithAlias(() => dto.Client);
}
and call it like
return Session.QueryOver<InvoiceDto>()
.SelectList(GetList())
.TransformUsing(Transformers.AliasToBean<InvoiceDto>())
.List<InvoiceDto>();
Problem
Is there a way to get a list of members from a function that can be passed in to SelectList()? So instead of doing this ``` var dtos = repository.QueryOver<MicrofilmExportProcessed>() .SelectList(list => list .Select(x => x.Member1).WithAlias(() => dto.Member1) .Select(x => x.Member2).WithAlias(() => dto.Member2) .Select(x => x.Member3).WithAlias(() => dto.Member3)) .List<MicrofilmExportProcessed>(); ``` Doing something like this: ``` var dtos = repository.QueryOver<MicrofilmExportProcessed>() .SelectList(getMembersFromFunc()) .List<MicrofilmExportProcessed>(); ``` I tried creating method that returns the same type as the input parameter of the SelectList but it still tells me the input type is invalid. Not sure what I'm missing.