c# - If Else in linq with anonymous object -
how if else conditional in linq query?
cashierdata.usedenominations boolean type, i'm doing casting same object . like
iqueryable<cashierbalance> icashierbalance = _cashierdatamanagement.getiqueryablecashierbalance(); var currencies = icashierbalance.select(a => new { id = a.currency.id, name = a.currency.name, simbol = a.currency.symbol, shorname = a.currency.shortname, roundingup = a.currency.roundingup, roundingdown = a.currency.roundingdown, denominationmin = a.currency.denominationmin, denominations = cashierdata.usedenominations ? (denomination) a.currency.denominations.select(q => q ) : (denomination) null });
the response api
unable cast type 'system.collections.generic.ienumerable`1[[tellers.denomination, dynamicfieldsdiagramlib, version=1.0.0.0, culture=neutral, publickeytoken=null]]' type 'tellers.denomination'. linq entities supports casting edm primitive or enumeration types.
without casting
iqueryable<cashierbalance> icashierbalance = _cashierdatamanagement.getiqueryablecashierbalance(); var currencies = icashierbalance.select(a => new { id = a.currency.id, name = a.currency.name, simbol = a.currency.symbol, shorname = a.currency.shortname, roundingup = a.currency.roundingup, roundingdown = a.currency.roundingdown, denominationmin = a.currency.denominationmin, denominations = cashierdata.usedenominations ? a.currency.denominations.select(q => q ) : null });
the exception
the nested query not supported. operation1='case' operation2='collect'
the problem iqueryable
attempting parse expression , convert sql expression. beyond capabilities of entity framework (specifically, unable assign enumerable of objects denominations
).
in case, want fetch data database, perform conversion in .net client.
to achieve this, convert iqueryable
linq2objects
invoking asenumerable
.
iqueryable<cashierbalance> icashierbalance = _cashierdatamanagement.getiqueryablecashierbalance(); var currencies = icashierbalance .asenumerable() .select(a => new { id = a.currency.id, name = a.currency.name, simbol = a.currency.symbol, shorname = a.currency.shortname, roundingup = a.currency.roundingup, roundingdown = a.currency.roundingdown, denominationmin = a.currency.denominationmin, denominations = cashierdata.usedenominations ? a.currency.denominations.select(q => q ) : null });
Comments
Post a Comment