I cannot return my query when I group data. Please check my issue
public IQueryable<GroupModel> GetAll()
{
List<Category> listCategories = new List<Category>
{
new Category {Id = 1, CateName = "SmartPhone", Description = "aaaaaa"},
new Category {Id = 2, CateName = "Laptop", Description = "bbbb"},
new Category {Id = 3, CateName = "Desktop", Description = "ccccc"},
};
List<Product> listProducts = new List<Product>
{
new Product {Id = 1, ProdName = "Lumia 720", CategoryId = 1, ColorId = 2},
new Product {Id = 2, ProdName = "PC HP", CategoryId = 3, ColorId = 1},
new Product {Id = 3, ProdName = "PC Dell", CategoryId = 3, ColorId = 1},
new Product {Id = 4, ProdName = "Laptop Lenovo", CategoryId = 2, ColorId = 2},
new Product {Id = 5, ProdName = "Lumia 920", CategoryId = 1, ColorId = 2},
new Product {Id = 6, ProdName = "Laptop Dell", CategoryId = 2, ColorId = 3},
new Product {Id = 7, ProdName = "Laptop HP", CategoryId = 2, ColorId = 3},
new Product {Id = 7, ProdName = "Lumia 1020", CategoryId = 1, ColorId = 1}
};
var query = (from p in listProducts
join co in listColors on p.ColorId equals co.ColorId
join c in listCategories on p.CategoryId equals c.Id into e
from j in e.DefaultIfEmpty()
select new GroupModel
{
CategoryId = j.Id,
CategoryName = j.CateName,
ProductId = p.Id,
ProductName = p.ProdName,
ColorId = co.ColorId,
ColorName = co.ColorName
}).ToList().GroupBy(x => x.CategoryName);
return query.AsQueryable();
}