I'm trying to return a join to my class and It is giving me the following error.
Error 1 Can not implicitly convert type 'System.Collections.Generic.List' to 'System.Collections.Generic.List' C:\Projetos_ASP.NET\AdvanceTechniques\Models\Repository\ProductRepository.cs 40 30 AdvanceTechniques
Follows the code below.
public List<Line> Get()
{
return context.
Lines.
Join(
context.Products,
lines => lines.ID,
products => products.LineID,
((products, lines)
=> new { lines, products}
)).
OrderByDescending(products => products.products.ID).ToList();
}
Follow my Entity
public partial class Line
{
public Line()
{
this.Products = new List<Product>();
}
[Required]
public long ID { get; set; }
[Required]
public string Name { get; set; }
[Required]
public string Slug { get; set; }
[Required]
public string DesktopImage { get; set; }
[Required]
public string MobileImage { get; set; }
[Required]
public string AltImage { get; set; }
[Required]
public int Position { get; set; }
[Required]
public bool IsActive { get; set; }
public virtual List<Product> Products { get; set; }
}
You don't need a Join to return products for each line, you only have to Include Products and then return them like:
return context.Lines.Include("Products").ToList();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With