Q: Can not get data after compare two tables I have 2 tables which have their own slug. I want to compare slug by an action to filter the post to show on view to user. This is my LINQ, but it's not working.
public ActionResult BaiViet(string slugCategory, string slugPost)
{
    var model = db.Posts.Single(p => p.slug.Equals(slugPost)
                                     && p.catID.Equals(db.Categories.Single(c => c.slug.Equals(slugCategory)).catID)
                    );
    return View(model);
}

I tried this but still not working :(
public ActionResult BaiViet(string slugCategory, string slugPost)
{
    var model = (from c in db.Categories
                 from p in db.Posts
                 where c.catID == p.catID
                       && c.slug == slugPost
                       && p.slug == slugCategory
                 select p).FirstOrDefault();
}


A: Solution posted by author in his original post:
var model = (from p in db.Posts
                join c in db.Categories
                    on p.catID equals c.catID
                where
                    p.slugPost == slugbaiviet
                    && c.slugCat == slugchuyenmuc
                select p).FirstOrDefault();

