group by c#

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
Eje211 80 points

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

0
0
3
2
F Inta 100 points

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

3 (2 Votes)
0
4.4
5
SoledadBro 85 points

                                            //Method Syntax

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

    

4.4 (5 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
using a method in a group by linq a linq group clause results using groupby linq group by string linq linq groupby and get specific item from list c# groupby and then select where c# groupby where c# group by specific value c# group by where method group in c# linqtosql group by group keyword c# c# groupby implementation linq group by example in c# select group by linq C# Grouping group by id linq group by and to list c# linq groupby in c# how group by works in linq linq group by aggregate linq group by in details c# c# group by reference group group by using linq to sql Groupby in linq to sql group by list c# group by using linq c# c# method group group by using linq c# group by id linq group bu c# select group by group by linq to sql list c# group by group in linq how to group by in linq c# linq from group by c# groupby and select 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 group by in linq query c# .net linq GroupBy group by example in linq c# linqu group by linq to sql group by example c# linq groupby example c# group by linq examples linq .FromSql groupby linq groupby sql group by in group by linq what doies groupby do linq sql linq group bu .GroupBy linq linq example of a group by group by linq example with model c# group by in model linq c# group by linq example linq groupby select in c# c# linq group with where select query linq c# group requete linq group by linq simple group by linq group by id c# linq where on groupby sql server group by linq linqtodb group by ling group by group by with where clause in linq c# linq group by and having groupby with select linq linq group by variable linq group c# select in group by linq c# linq group by and order by 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 linq group by and aggregate group by in linq in c# c# groupby example linq linq: group by column linq group by having c# linq group by then group by group by in linq sql group by and select in linq linq group by c# 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 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. 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 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 linq group by asenumerable linq select and group by linq group by then order group by group by in linqc# c# linq group by inside group by group by linque 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 groupby linq c# example linq query syntax group by linq with where and group by in c# linq where with group by c# group by in linq method query c# linq group by and take from each group linq query with group by in 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 grouping 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 group function group by linq groupby and orderby linq what is the use of GroupBy in linq linq group by get field group by c# linq c# linq group by where linq select group by c# groupby linq sql query group results in linq linq group by list linq query group by with where clause linq group by method syntax group by in linq with where clause c# linq group by example group by clause linq c# linq group into complex object use alements&ugrave; group by clause group into linq c# group linq group by clause in linq Grouping c# c# group by linq example 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 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 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 linq c# group by 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 c# linq group by group functions in dotnet core c# groupby 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# c# group by linq 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# 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