Show / Hide Table of Contents

    IDataStore.GroupBy() Method

    .NET Standard 2.x

    Groups all rows of the primary buffer by the current grouping criteria of DataStore.

    Namespace: DWNet.Data

    Assembly: DWNet.Data.dll

    Syntax

      public IEnumerable<IGrouping<object, IGroupingGetter>> GroupBy();
    

    Returns

    System.Collections.Generic.IEnumerable<IGrouping<System.Object, DWNet.Data.IGroupingGetter>>

    Returns an IEnumerable<IGrouping<Object,IGroupingGetter>> object which can be used to read data in groups.

    Examples

    The 'd_department_course' contains two levels of groups: the primary group is grouped by course_departmentid; the nested group is grouped by course_courseid. The following code example demonstrates how to get the primary group and return the data of this group.

    using Appeon.ApiDoc.Models;
    using DWNet.Data;
    using System;
    using System.Collections.Generic;
    using System.Linq;
    
    namespace Appeon.ApiDoc.IDataStoreExamples
    {
        public class GroupByExample
        {
            private readonly SchoolContext _context;
    
            public GroupByExample(SchoolContext dataContext)
            {
                // Sets the data context
                _context = dataContext;
            }
    
            public void Example1()
            {
                // Instantiates a DataStore object with datawindow: d_department_course.
                var datastore = new DataStore("d_department_course", _context);
    
                datastore.Retrieve();
    
                // The primary group is by course_departmentid which has only 4 values.
                var departmentGroup = datastore.GroupBy();
    
                Console.WriteLine("Department Group Count: {0}",
                                  departmentGroup.Count());
    
                /*This code produces the following output:
                 
                Department Group Count: 4
                */
            }
        }
    }
    

    Example Refer To

    Model Class: D_Department_Course
    DataWindow File: d_department_course

    Applies to

    .NET Standard

    2.x

    Back to top Generated by Appeon