I am trying to create a list of custom objects in LINQ, and I am not sure how to do it. Here is my classes...
public class MenuModel
{
public IList<MenuCategoriesWithArticles> Menu { get; set; }
}
public class MenuCategoriesWithArticles
{
public Category Category { get; set; }
public IList<Article> Articles { get; set; }
}
and I would like to create MenuModel from the following functions that return Category and IList in order.
businessCategory.GetAllCategories();
businessArticle.GetArticlesByCategory(int categoryId);
I have something like below but I am not sure...
businessCategory.GetAllCategories().Select(x=> new .....)
any help would be great. I dont want to loop to get each categories' articles.
GetArticlesByCategory()requires acategoryId.