use*_*480 2 c# linq-to-entities
我有一个类库,用于保存我的数据库的实体框架数据模型.出于测试目的,我在名为test.cs的库中创建了一个类,并添加了此代码以查看是否一切正常:
var db = new EmailTestEntities();
var x = from p in db.Emails
orderby p.Created
where p.EmailRouteID == 4
select new {p.ID, p.MessageDate};
foreach (var y in x)
{
var z = y.ID;
}
Run Code Online (Sandbox Code Playgroud)
每件事都有效,所以我将完全相同的代码添加到我的Web应用程序中,该应用程序具有对我的库的引用和用于引用的using语句.
但是,我收到以下错误:
Could not find an implementation of the query pattern for source type 'System.Data.Objects.ObjectSet`1<EmailTestLibrary.Email>'. 'OrderBy' not found.
Run Code Online (Sandbox Code Playgroud)
为什么代码在库中工作但在我的Web代码中不起作用?
谢谢!