linq group by

var results = from p in persons
              group p.car by p.PersonId into g
              select new { PersonId = g.Key, Cars = g.ToList() };

0
8
F.X. 70 points

                                    public class DeliverableGroupContainer
{
    public Crew Crew;
    public DateTime Date;
    public List<Deliverable> Deliverables;
}

List<DeliverableGroupContainer> Deliveries =
         Db.Deliveries
           .Where(d => d.CrewId != null)
           .GroupBy(d => new {d.Crew, d.Date})
           .OrderBy(d => d.Key)
           .Select(g => new DeliverableGroupContainer()
                        {
                            Crew = g.Key.Crew,
                            Date = g.Key.Date,
                            Deliverables = g.ToList()
                        })
           .ToList();
//------------------------------Example----------------------------------
 var drAll3 = dt.AsEnumerable().GroupBy(d => new { d.Field<DateTime>("date").Date, V = d.Field<String>("supplierArticle") })
                         .Select(g => new { _Date = g.Key.Date , Article = g.Key.V, Qty = g.Sum(r => r.Field<int>("quantity")) }).ToList();


            DataTable dt4 = StatHellpers.LINQResultToDataTable(drAll3);

0
0
4.63
8
Kijitora 120 points

                                    var results = persons.GroupBy(
    p => p.PersonId, 
    p => p.car,
    (key, g) => new { PersonId = key, Cars = g.ToList() });

4.63 (8 Votes)
0
4
2

                                            //Method Syntax

        List<Result> results2 = persons
            .GroupBy(p => p.PersonId, 
                     (k, c) => new Result()
                             {
                                 PersonId = k,
                                 Cars = c.Select(cs => cs.car).ToList()
                             }
                    ).ToList();

    

4 (2 Votes)
0
Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
grouping linq linq select where group by linq group by method syntax group by having linq c# group by and select linq linq group by order using a method in a group by linq a linq group clause results c# linq group by from datagrid c# linq group by from class c# linq group by class using groupby linq group by string linq linq groupby and get specific item from list c# linq group by enums linqtosql group by c# linq group by list of string c# linq groupby orderby c# linq group list by linq group by example in c# c# sql linq group by group by and order by linq c# select group by linq group by id linq linq groupby in c# c# linq grouping how group by works in linq linq group by aggregate linq group by in details c# group by using linq to sql Groupby in linq to sql group by using linq c# group in c# linq group by using linq linq group bu linq query group by c# group by linq to sql group in linq how to group by in linq c# linq from group by linq with group by example in c linq group by query in c# linq with group by example in c# linq c# group by example c# linq group by namew and occurrence group by in linq query c# .net linq GroupBy group by example in linq c# c# linq groupby equals linqu group by linq to sql group by example c# linq groupby example c# group by linq examples c# ling group by dot net : linq group by expressions c# linq group by select list linq .FromSql groupby linq groupby sql group by in group by linq linq expression group by c# what doies groupby do linq sql linq group bu group by linq c# list .GroupBy linq linq example of a group by c# linq group by valeus group by linq example with model c# group by in model linq c# group by linq example how use group by in linq to get all the data in c# linq groupby select in c# linq where and group by c# group by select new linq c# C LINQ group by select c# linq group with where select query linq c# group from ... in group query linq c# group requete linq group by linq simple group by linq group by id c# group linq linq where on groupby sql server group by linq linqtodb group by c# linq group by foreach ling group by group by with where clause in linq c# total linq group by c# linq group by and having groupby with select linq list group by linq c# linq group by variable dynamic group by linq c# linq group c# select in group by linq c# linq group by and order by c# apply groupby by using linq on select list in c# GroupBy linq by 4 filds c# linq group by from list group by with orderby linq linq sql group by group by where as linq c# linq groupby where linq group by docs linq to sql group rows by name linq group by id sql linq to sql group by dot net: group by linq examples linq group by and aggregate group by in linq in c# c# groupby example linq group linq c# linq: group by column c# linq group and select linq group by having group by on list of object in linq c# group by on list in linq c# c# linq group by then group by group by in linq sql group by and select in linq linq group by c# select linq groupeby c# c# linq group by all columns groupby in linq list c# linq groupby example where with group by linq group by linq linq group by select group by select in linq c# syntax linq group by select to list groupby linq examples linq group c# linq group linq group by then where group by in linq group by clause in a linq query groupby clause in a linq query c# linq groupby example how to use list group by in linq c# linq c# group by from list to list linq c# group by from list linq gropu by c# linq query group by example where and group by linq c# linq group by columns c# linq group by select new object c# linq group. LINQ GROUP BY ITEM IN LIST linq group by where linq group by result c# group by into linq method c# linq group by select group by linq query in c# GroupBy() linq linq group by get values c# linq group by sql format c# linq group by sql form c# group by linq linq group by and select how to group by linq linq query group by clause linq can use where for group by c# linq sql group by linq group by vb.net group by linque linq group by asenumerable linq select and group by linq group by then order group by list group by c# linq group by in linqc# c# linq group by inside group by c# linq group select linq group by syntax c# linq group by expression linq group by into list linq grup by group by and return list linq group by and list linq C# linq groupby order by groupby linq c# example linq query syntax group by linq .select to group by c# c sharp group by linq linq with where and group by in c# linq where with group by c# c# linq group iwth or group by in linq method query c# group by linq list c# linq group by and take from each group linq query with group by in c# group clause in linq c# group by id in linq c# can you group by in linq with a select can you group by in linq linq to group linq group by example c# linq group by expression linq group by. what does groupby linq query do linq method syntax group by linq example c# group by group by linq extract linq group by id linq group by each value in list c# linq grouping group by object c# linq groupby then select in linq c# groupby in linq c# where group by linq c# linq group by syntax c# c# linq method syntax groupby linq c# sintassi groupby linq group function group by linq groupby and orderby linq group by list in linq c# group by with having clause in linq c# what is the use of GroupBy in linq linq group by get field group by with having in linq c# c# linq group by and project group by c# linq c# linq group by where linq select group by c# groupby linq examples c# groupby linq sql query group results in linq linq group by list linq query group by with where clause group linq in c# c# linq group by on dataset group by in linq with where clause c# linq group by example linq c# group by list<> group by and select in c#linq group by clause linq c# linq group into complex object use alementsù group by clause group into linq c# group by clause in linq Grouping c# c# group by linq example how to loop group by linq c# linq with group and where by c# c# linq group to next groupby c# linq list groupby c# c# ilist group by query syntax linq group by get object group by in linq lambda c# linq group by query syntax linq group by c# example group by column linq linq with group by c# c# linq group by tutorial GROUP BY ON LINQ RESULT linq aplly groupby to a query how to use group by in linq c# linq to group by groupby a list by a property c# linq linq group by order by csharp linq group by get key csharp linq group by Enumerable.GroupBy Method (System.Linq) groupby code example c# Grouping Results with LINQ c sharp Enumerable.GroupBy Method syntax c sharp group by syntax in linq c# group in linq c# grouby linq group by in linq query syntax C# Linq GroupBy group by lnq c# linq group by microsoft groupby individual linq list to linq with group linq group by example group by in c# group by in linq query linq groupby c# how to use group by in linq c# linq query group by select c# groupby linq squery c# linq with group by use group by in linq string.groupby c# groupby in linq group by in linq c# example group by example c# linq group by] c# linq query group by group by c# example how to do group by in linq c# linq group by linq group and where in linq c# how to use when after group clause in linq c# how to group by in linq how to use the group by in C# c# group by what does group by do linq .net linq group by Linq Groupe by use where in group by in linq c# use groupby linq linq groupby linq group by LINQ query groupby c# group basic group by linq query asp.net groupby asp.net linq group by group by list c# linq example Group By linq id get name non query GroupBy linq groupby in c group functions in dotnet core c# groupby compare group of methods to group c# linq query select group by c# linque group list using group by in c# group by in linq c# linq group by in c# GroupBy in C# GroupBy ion C# select key.value not getting in sql .net core group by in c# linq linq to group by c# add group by in linq c# c# groupby example group by c# linq example group by c# C# linq group by linq group by query linq query group by group by clause in linq c# group by linq c# linq group by groupby linq c#
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source