开发者

Entity framework LINQ query 2 tables

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜