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

前端 未结 4 638
离开以前
离开以前 2020-12-11 02:29

I\'ve read ALL of:

  • Unable to create a constant value of type 'System.Object' in Entity Framework

  • Entity Framework - "Unable to

4条回答
  •  天命终不由人
    2020-12-11 03:21

    It will not work because you want to use local Album in linq-to-entities query. You must either use navigation property on p to get its album:

    var query = from p in VisibleObjects.OfType()
                where p.Album.Id == alb.Id
                select p;
    

    or you must build complex query with some join between photos and albums. You cannot pass local object and any its relation to the query. Only simple properties can be passed.

提交回复
热议问题