c# - Calculated field in model class gives exception -


i'm getting exception when executing linq query:

the specified type member 'active' not supported in linq entities. initializers, entity members, , entity navigation properties supported.

model class

public class user : entity {      //many properties skipped       [notmapped]         public bool active         {                         {                return orders.any(c =>                  c.active && (c.transactiontype == transactiontype.order ||                              c.transactiontype == transactiontype.subscription));             }         }  } 

the linq query gives exception

public ienumerable<user> getinactiveusersforsuspensionnotification() {     return _userrepository.getall()         .include(i=>i.orders)         .where(w => w.active == false); } 

orders related table users.

when using linq entities linq expression converted sql query sent database. whole table not pulled memory.

your problem because active not mapped database knows nothing , therefore cannot make calculation.

you either need move active db or change linq statement query on columns in db


Comments

Popular posts from this blog

google app engine - 403 Forbidden POST - Flask WTForms -

Android layout hidden on keyboard show -

Parse xml element into list in Python -