Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
实体框架LINQ查询2表_Linq_Entity Framework - Fatal编程技术网

实体框架LINQ查询2表

实体框架LINQ查询2表,linq,entity-framework,Linq,Entity Framework,我无法在db.Restaurants对象上使用Include(“CITies”)扩展方法 使用include时,出现以下错误: DL.RESTAURANT不包含包含的定义或包含的扩展方法 namespace DL { public class DLgetRestaurants { DL.FVRGDataContext db = new FVRGDataContext(); public IEnumerable <RESTAURANT>

我无法在
db.Restaurants
对象上使用
Include(“CITies”)
扩展方法

使用include时,出现以下错误:
DL.RESTAURANT不包含包含的定义或包含的扩展方法

namespace DL
{
    public class DLgetRestaurants
    {
        DL.FVRGDataContext db = new FVRGDataContext();

        public IEnumerable <RESTAURANT> getRestaurants(string cuisineName)
        {
           var restaurantList = 
               from RESTAURANT in db.RESTAURANTs.Include("CITies")
               where RESTAURANT.CITies.Any(t => t.CITY_ID == 2)
               orderby RESTAURANT.REST_NAME ascending
               select RESTAURANT;

            return restaurantList;
         }
     }
}
名称空间DL
{
公营餐厅
{
DL.FVRGDataContext db=新的FVRGDataContext();
公共IEnumerable getRestaurants(string cuisineName)
{
var restaurantList=
来自db餐厅中的餐厅。包括(“城市”)
where RESTAURANT.CITies.Any(t=>t.CITY\u ID==2)
orderby RESTAURANT.REST\u名称升序
选择餐厅;
返回餐厅列表;
}
}
}

只能在与另一个表有关系的实体上使用“包含”。除此之外,你不应该有问题。

@Aducci那是我的错,不小心把它删掉了。它是back
db.RESTAURANTS
的数据类型是什么?您是否将命名空间
System.Data.Entity
添加到您的文件中?不,我没有。。。。Intellisense似乎找不到“Entity”db是我的DataContext文件,Retaarant是我的Entity framewaor中的一个表。餐厅表与城市表具有外键关系。我已经用这些表(和其他表)设置了datacontect文件。这还不够吗?