GithubHelp home page GithubHelp logo

karenpayneoregon / grouping-basics-csharp Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 1.0 575 KB

Provides basic code samples for a developer to learn basics for grouping data

C# 94.44% TSQL 5.56%
console-application csharp-core efcore5 grouping json

grouping-basics-csharp's Introduction

Basic to intermediate grouping with C#

Learn the basics of grouping data with models and DataTable.

Rather than get extremely complex, most of the examples are simple for learning purposes. Best way to learn from these code samples is start with those starting with Sample with a number, so start with Sample1 and run through to Sample5.

Run each project one at a time, look at the results then go back and step through the code with Visual Studio’s debugging and examine data in Visual Studio’s local window.

Once these samples make sense do the same for projects under the Advance Solution Explorer folder. Run, go back and study the code.

By understanding all the code samples provides a base for more advance group by operations.

Note Other than the project GroupByMultipleProperties all other examples rerquire no database while GroupByMultipleProperties requires SQL-Server as this project uses Entity Framework Core.

One of several code samples

Screenshot

partial class Program
{
    static void Main(string[] args)
    {
        var grouped = Mock.Books()
            .GroupBy(group => group.AuthorName)
            .Select(grouping => new AuthorListing(grouping.Key, grouping.ToList()
                .Select(book => book.Titles.ToList())))
            .ToList();

        foreach (AuthorListing listing in grouped)
        {
            Console.WriteLine(listing.Author);
            foreach (var title in listing.Titles)
            {
                Console.WriteLine($"\t{title}");
            }

            Console.WriteLine();

        }

        Console.ReadLine();
    }
}

Another using EF Core 6

x

grouping-basics-csharp's People

Contributors

karenpayneoregon avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Forkers

bionstt

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.