A constant variable of type 'System.Object' could not be created. In this environment, only primitive types ('such as Int32, String, and Guid') are supported.

entity-framework linq-to-entities

Question

I'm using Entity Framework and MVC. With the code shown below, I've built a class in my model folder. With both of the following queries, I continue to get the error notice. I'm aware that referring non-scalar variables is a recognized problem, but I'm not sure how to fix it:

http://msdn.microsoft.com/en-us/library/bb896317.aspx#Y1442

private MovieLibraryDBEntities movieLibraryDBEntitiesContext;

public int getNumberOfEntriesReserved()
{
    return (from m in movieLibraryDBEntitiesContext.Movies
            where m.CheckedOut.Equals(1)
            select m).Count();

    //return movieLibraryDBEntitiesContext.Movies
    //  .Where(e => e.CheckedOut.Equals(1))
    //  .Select (e => e.Title).Count();
}
1
8
5/7/2011 7:46:05 PM

Popular Answer

You cannot usem.CheckedOut.Equals(1) the query for linq-to-entities. Usem.CheckedOut == 1 but CheckedOut has to beinteger .

14
5/7/2011 7:44:58 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow