开发者

asp.net mvc nerddinner question linq to entities join question

I am working on a website similar to nerddinner. Is it possible to perform similar join using Linq to entities what is done with linq to sql in nerddinner. I am posting the codes below.

public IQueryable<Dinner> FindByLocation(float latitude, float longitude) {
        var dinners = from dinner in FindUpcomingDinners()开发者_Go百科
                      join i in db.NearestDinners(latitude, longitude) 
                      on dinner.DinnerID equals i.DinnerID
                      select dinner;

        return dinners;
    }

I want to replace this codes with linq to entities implementation.

Regards

Parminder


Could you just look for where they intersect like:

FindUpcomingDinners().Intersect(db.NearestDinners(latitude, longitude)).ToList();

I am not sure what FindUpcomingDinners returns but the easiest would be to have two functions that return IEnumerables for FindUpcomingDinners and NearestDinners and then just get the intersect of the two lists.

Eg:

List<Dinner> upcomingDinners = FindUpcomingDinners();
List<Dinner> nearestDinners = NearestDinners(latitude, longitude);

List<Dinner> result = upcomingDinners.Intersect(nearestDinners).ToList();
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜