开发者

Entity framework LINQ query 2 tables

开发者 https://www.devze.com 2023-03-18 16:27 出处:网络
I am unable to use the Include(\"CITies\") extension method on the db.Restaurants object. When I use the include I get the following error:

I am unable to use the Include("CITies") extension method on the db.Restaurants object.

When I use the include I get the following error: DL.RESTAURANT does nto contain a definition for include or an extension method of include

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;
         }
     }
开发者_JAVA技巧}


You can only use the Include on Entities that have a relation with another table. Other than that you shouldn't have an issue.

0

精彩评论

暂无评论...
验证码 换一张
取 消