0

This is my method:

public IEnumerable<Web_Vendor> GetSaleBrands()
{
    using (var _db = new LuxedecorContext())
    {
        IQueryable<Web_Vendor> web_vendors = _db.Web_Vendor.
        Where(x =>
        (_db.Web_Promotion.Where(z => z.VendorID != string.Empty
            && z.Static == true && z.Percent != 0 &&
            (x.WebPromotion.Expires >= DateTime.Now || x.WebPromotion.Expires == null))
            .Select(r => r.VendorID).Contains(x.VendorID))
        ||
        (_db.NavItems.Where(y => x.WebPromotion.VendorID == y.SC1
            && !(y.Promotion == "" || y.Promotion == null)
            && (y.PromotionStart <= DateTime.Now) && (y.PromotionEnd >= DateTime.Now || y.PromotionEnd == null))
            .Select(g => g.SC1).Contains(x.WebPromotion.VendorID)))
        .Where(x => x.Active == true).OrderBy(x => x.NameExtra)
        .ThenBy(x => x.Sequence);

        var a = web_vendors.ToList(); // 16 values
        var b = web_vendors.Include(x => x.WebPromotion).ToList(); // 13 values
    }
    throw new NotImplementedException();
}

I need to Include nullable values to my collection of Web_Vendors. I know, it's famous question, but I need to return collection of Web_Vendors instead of collection of dynamic types. Is it possible?

Jon Skeet
  • 1,421,763
  • 867
  • 9,128
  • 9,194
Alex Gurskiy
  • 263
  • 1
  • 5
  • 14
  • Take a look at this article on how to do the left joins in linq: https://msdn.microsoft.com/en-us/library/bb397895.aspx if you want to do it using lambda conventions take a look at this reply: http://stackoverflow.com/questions/584820/how-do-you-perform-a-left-outer-join-using-linq-extension-methods – Łukasz Trzewik Dec 04 '15 at 12:07
  • It's not very clear what you are trying to do here. It would help if you explained the relationship between your different business entities of `Web_Vendor`, `WebPromotion`, and `NavItem`. It would also help if you explained what business domain problem you are trying to solve. – skeletank Dec 04 '15 at 13:22
  • I need to do a left outer join. – Alex Gurskiy Dec 04 '15 at 13:56

0 Answers0