我正在使用MVC和實體框架。我在我的模型文件夾中創建了一個類,下面是這個代碼。我不斷收到上面的錯誤消息以及下面的兩個查詢。我知道引用非標量變量存在一個已知問題,但我不確定如何實現變通方法:
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();
}
您不能在linq-to-entities查詢中使用m.CheckedOut.Equals(1)
。使用m.CheckedOut == 1
但CheckedOut
必須是integer
。