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

后端 未结 4 469
旧巷少年郎
旧巷少年郎 2020-12-11 14:45

I have a table named UserTenders having many-to-one relationship with aspnet_Membership table.
I am using EntityFramework 4.0 and when I try so

4条回答
  •  误落风尘
    2020-12-11 15:14

    I had the same exception caused by a different problem: a char versus a string used as a constant. My select looked like this:

    from p in Person
    select new Foo
    {
      FullName = p.FirstName + ' ' + p.LastName
    }
    

    The boolean conditionals I had elsewhere in the query (i.e. "where p.IsActive") worked fine. I had to switch to using a string:

    from p in Person
    select new Foo
    {
      FullName = p.FirstName + " " + p.LastName
    }
    

    This obviously is not the answer to the OP's question, but I was unable to find a similar question with the char/string issue so I wanted to post it for others' benefit.

提交回复
热议问题