Hi Everyone,
var products = unitOfWork.Products.GetAll() .Include(i => i.ProductDetails).Where(d=>d.ProductDetails.Any(i=>i.LanguageId==2)).ToList();
I have these two tables. I want to write the following sql code with entityframework. I tried the above code that doesn't work.
SELECT * FROM [dbo].[Products] P LEFT OUTER JOIN [dbo].[ProductDetails] PD ON P.ProductId = PD.ProductId WHERE PD.LanguageId=2
namespace MIS.WebUI.Entity { public class Product { public int ProductId { get; set; } public string ProductCode { get; set; } public string Image { get; set; } public ICollection<ProductDetail> ProductDetails { get; set; } } }
namespace MIS.WebUI.Entity { public class ProductDetail { public int ProductDetailId { get; set; } public int LanguageId { get; set; } public DateTime UpdateDate { get; set; } public string ProductName { get; set; } public string Description { get; set; } public string HtmlContent { get; set; } public double Price { get; set; } public int Currency { get; set; } public bool TaxIncluded { get; set; } public bool IsApproved { get; set; } public bool IsHome { get; set; } public bool IsFeatured { get; set; } public int? ProductId { get; set; } public Product Product { get; set; } } }