c# - Entity framework do case on discriminator -
is there way cast within query subclass?
if quering single subclass
auctions.oftype<auctionbid>().where(auctionbid => auctionbid.auctionbidprop) now case on type of subclass
class="lang-cs prettyprint-override">auctions.where(auction => (auction auctionbid) && ((auctionbid) auction).prop == 1 || (auction auctionbuy) && ((auctionbuy) auction).prop == 1) is there way it?
of course of study line above gives error: linq entities supports casting edm primitive or enumeration types.
the alternative see query sub types separately , concatenate results:
auctions.oftype<auctionbid>() .where(auctionbid => auctionbid.auctionbidprop == 1) .cast<auctionbase> .concat(auctions.oftype<auctionbuy>() .where(auctionbuy => auctionbuy.auctionbidprop == 1) ) .orderby(ab => ab.prop1) .skip(pages * pagesize) .take(pagesize) this generate union all query. not efficient approach when compared hand-crafted sql, maybe acceptable (you'll have try).
c# linq entity-framework
No comments:
Post a Comment