c# - Expression - Unable to create a constant value of type 'System.Collections.Generic.List`1'. Only primitive types ('such as Int32, String, and Gu -


i have written following lambda expression

expression<func<contractobject, bool>> objexpression =  => i.contractprojects.any(a => projectlist.any(p => p.id == a.projectid)); 

contractprojects , projectlist list of 2 different types sharing common values ie. projectid , id respectively.

but throwing following exception. there changes have or can expression written in way?

unable create constant value of type 'system.collections.generic.list`1'. primitive types ('such int32, string, , guid') supported in context.

i think problem contractlist might not have been created yet

try :

var objexpression = => i.contractprojects.tolist()                           .any(a => projectlist.any(p => p.id == a.projectid)); 

Comments