Unable to create a constant value of type 'System.Object'. Only primitive types ('such as Int32, String, and Guid') are supported in this context

前端 未结 3 1634
时光说笑
时光说笑 2021-01-18 00:18

I\'m using MVC and Entity Framework. I\'ve created a class in my model folder with this code below. I keep getting the error message above with both queries below. I know

3条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-18 01:10

    same issue using Any() i had to change my where clause to search on primitive types, for me int

    so this

    where order.User == user
    

    becomes this

    where order.User.UserId == user.UserId
    

    There is a blog post explaining the quirk.

提交回复
热议问题