c# - Unable to create a constant value of type 'Closure type'. Only primitive types ('such as Int32, String, and Guid') are supported in this context -
i have table name otherearninganddeduction in sql server , there few columns
columns datatype 1). id guid primary key. 2). salaryheadid guid fk. 3). month varchar 4). academicyearid guid fk 5). ..... 6). ..... 7). ..... and want check whether same record present in table or not using linq in asp.net. , restrict inserting record record present in table.
manager object of entity.
otherearninganddeduction obj =new otherearninganddeduction(); var dublicatecheck=manager.otherearninganddeduction.where(x=>x.salaryheadid==obj && x.month==obj.month && x.academicyearid==obj.academicyearid).tolist(); i getting error on above line...
unable create constant value of type 'closure type'. primitive types ('such int32, string, , guid') supported in context.
so plese me...
i'm not 100% certain, think problem because compare x.salaryheadid obj, instead of obj.salaryheadid.
i think work:
var dublicatecheck=manager.otherearninganddeduction.where(x=>x.salaryheadid==obj.salaryheadid && x.month==obj.month && x.academicyearid==obj.academicyearid).tolist(); in code, you're trying compare salaryheadid property (field) of x instantiated object, not instantiated object's salaryheadid property (field). hence error message.
Comments
Post a Comment