asp.net mvc - how return multiple column in join result to view model -
i want return multiple column in join result , fill in view model(vmfoodfoodmeal
). example want fill vmfoodfoodmeal
join result thanks
ienumerable<vmfoodfoodmeal> _fmt = (from e in db.foodprogrammealfood join j in db.foods on e.foodid equals j.id select new { id = e.id, name = j.name, });
it hard understand want, example can here @ group join section.
here example code there:
public void linq103() { string[] categories = new string[]{ "beverages", "condiments", "vegetables", "dairy products", "seafood" }; list<product> products = getproductlist(); var q = c in categories join p in products on c equals p.category ps select new { category = c, products = ps }; foreach (var v in q) { console.writeline(v.category + ":"); foreach (var p in v.products) { console.writeline(" " + p.productname); } } }
result: beverages: chai chang guaraná fantástica sasquatch ale steeleye stout côte de blaye chartreuse verte ipoh coffee ...
Comments
Post a Comment