I have a product, this product can have some descriptions one by language.
I'd like based on the product.Reference and the Language.Code get the product and the description matching the language code. I use EF Core 2.0
I can do it with 2 separated query but I'd like one if it's possible.
I tried this :
var product = _context.Products
.Where(x => x.Reference == "3265709")
.Include(x => x.ProductDescriptions)
.ThenInclude(x => x.Where(lg => lg.Language.Code == "EN").Select(z => z.Language))
.ToList();
Any idea ?
Thanks,
public class Product
{
public int Id { get; set; }
public string Name { get; set; }
public string Reference { get; set; }
public ICollection<ProductDescription> ProductDescriptions{ get; set; }
}
public class ProductDescription
{
public int Id { get; set; }
public string Short { get; set; }
public string Complete { get; set; }
public Language Language{ get; set; }
public Product Product { get; set; }
}
public class Language
{
public int Id { get; set; }
public string Code { get; set; }
public string Name { get; set; }
}