C#在LINQ中使用左外连接

时间:2015-12-04 11:50:39

标签: c# entity-framework linq

这是我的方法:

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();
}

我需要在我的Web_Vendors集合中包含nullable值。我知道,这是一个着名的问题,但我需要返回Web_Vendors的集合而不是动态类型的集合。有可能吗?

0 个答案:

没有答案
相关问题