score:1
Accepted answer
List<MenuModel> lstMenuModel = dtable.AsEnumerable()
.GroupBy(x => new { ParentID = x["ParentID"], ParentName = x["ParentName"] })
.Select(x => new MenuModel()
{
ParentID = x.Key.ParentID,
ParentName = x.Key.ParentName,
MenuItems = x.Select(y => new MenuItemModel()
{
ChildID = y["ChildID"],
....
Source: stackoverflow.com
Related Query
- Need a alternate approch to do SQL to LINQ conversion
- Why do I need Stored Procedures when I have LINQ to SQL
- LINQ to SQL Conversion Overflows
- linq to sql left join, need to check for null for right table
- Need help with LINQ to SQL WHERE-clause on foreign table
- Need help in converting SQL query to LINQ
- LINQ update question comparing to SQL update. need help
- Select Max in Linq to Entities / Entity SQL with type conversion
- Need help translating from SQL to LINQ
- Conversion of Sql query to linq
- SQL to LINQ conversion C#
- Need help to write SQL query as a linq expression
- How to use c# to perform summing data with type conversion from SQL using LINQ
- Why do I need distinct with this LINQ query but not with SQL
- LINQ: bad conversion from LINQ to sql query
- Help needed on SQL query to Linq Conversion
- SQL conversion to LINQ - efficiency
- SQL to LINQ conversion with inner join and where filters on different tables
- Linqer SQL to LINQ conversion - Different results
- Need help with converting SQL to LINQ - LEFT JOIN with Count
- Need to Convert this SQL query to LINQ
- Linq Help need to convert to Linq Object model from sql model
- SQL to LINQ Conversion in C#
- I need to Update if exist else Insert with Linq to SQL
- SQL to LINQ Conversion - Group by
- LINQ to SQL entity to object conversion
- SQL Server ADO.NET Query conversion to Linq in WCF service
- I need Linq Query for this SQL Query
- Simple Sql query conversion to Linq To Sql
- SQL to Linq Conversion Issue
More Query from same tag
- Am I using QueryOver wrong?
- How to convert SELECT TOP 1 WITH TIES query to LINQ C#?
- EF Core Implement sql server DATEPART as DbFunction static method
- Proper way to use LINQ with CancellationToken
- OrderBy with value from another table
- Linq contains from ListItems
- LINQ to SQL Select Distinct by Multiple Columns and return entire entity
- Create a linq subquery returns error "Local sequence cannot be used in LINQ to SQL implementations of query operators except the Contains operator"
- How to do LEFT JOIN in LINQ to Entities?
- how to filter list which is inside List of class using linq?
- Difference between Expression<Func<>> and Func<>
- LINQ OrderBy only on second property
- How to write linq query comparing 2 tables?
- C# where does the dbml file come from?
- How to create Json Response with append child object to each it's parent object
- Return null instead default value in LINQ
- How to build a dynamic FROM clause for a LINQ query?
- Is there a pattern for "first best match" or predicate fallbacks in C#?
- Populating dropdown with LINQ query that has a calculated column
- Generics - get properties LINQ
- How to use linq with an aggregate , join and Group by
- Entity Framework join across two databases
- Build a nested lambda Expression Tree for an Entity Framework Many to Many relationship?
- replace List.foreach to LINQ
- EntityFramework / LinQ load entity from database to dto
- Divide in a Linq to SQL query
- Updating Collection from other collection for matching items
- Exclude an array in a LINQ expression that connects to CRM
- How to get the xml attribute value of root?
- Linq to Entities: Mixed graph of Entities, EntityKeys, Attached, and New Objects