QueryOver AliasToBean trying to set property on System.RuntimeType

110 views
Skip to first unread message

Mike Gibson

unread,
Mar 10, 2021, 4:15:56 PM3/10/21
to nhusers
I have a query that is giving my this error:

NHibernate.PropertyNotFoundException: Could not find a setter for property 'CompanyId' in class 'System.RuntimeType'

I have not been able to find anything that points to where this would come from. Most references to this online are about misspelled string names of properties but I am using lambda expressions for everything.

The query is below, note that DailyTransaction is polymorphic and subclasses can map to other tables or the DailyTransaction table. 

private IFutureEnumerable<AccountBalanceSummaryRecord> AccountBalanceSummary(Product product, ProductCycle productCycle)
{
DailyTransaction transaction = null;
TransactionType transactionType = null;
DailyTransactionProductValue productValue = null;
AccountGroup accountGroup = null;
Account account = null;
AccountBalanceSummaryRecord record = null;

return Session.QueryOver<DailyTransaction>(() => transaction)
.JoinEntityAlias(() => productValue, () => transaction.Id == productValue.DailyTransaction.Id)
.JoinAlias(() => transaction.TransactionType, () => transactionType)
.JoinAlias(() => transaction.DebitAccountGroup, () => accountGroup)
.JoinAlias(() => transaction.DebitAccount, () => account)
.Where(t => t.Product.Id == product.Id)
.And(t => t.Day == productCycle.Day)
.And(t => transactionType.Code != TransactionType.A)
.And(t => transactionType.Code != TransactionType.B)
.And(t => accountGroup.BusinessRight == BusinessRight.A)
.And(t => accountGroup.IsBalanced)
.And(t => account.AccountType == AccountType.TT)
.SelectList(l => l
.SelectGroup(() => transaction.Company.Id).WithAlias(() => record.CompanyId)
.SelectGroup(() => transaction.DebitAccountGroup.Id).WithAlias(() => record.AccountGroupId)
.SelectGroup(() => transaction.DebitLocation.Id).WithAlias(() => record.LocationId)
.SelectGroup(() => account.AccountType).WithAlias(() => record.AccountType)
.SelectSum(() => productValue.ScheduledValue).WithAlias(() => record.DebitScheduledValue)
.SelectSum(() => transaction.DebitValue).WithAlias(() => record.DebitValue)
)
.TransformUsing(Transformers.AliasToBean<AccountBalanceSummaryRecord>())
.Future<AccountBalanceSummaryRecord>();

I am also having an issue where 13 left joins from those polymophic tables are being added to the query.
Reply all
Reply to author
Forward
0 new messages