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)
.JoinAlias(() => transaction.TransactionType, () => transactionType)
.JoinAlias(() => transaction.DebitAccountGroup, () => accountGroup)
.JoinAlias(() => transaction.DebitAccount, () => account)
.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(() => 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.