IDataStore.GroupBy<TModel>() Method
.NET Standard 2.x | Current Version (1.0.1) 
Generic method. Groups all rows of the primary buffer by the current grouping criteria of DataStore.
Namespace: PowerBuilder.Data
Assembly: PowerBuilder.Data.dll
Syntax
public IEnumerable<IGrouping<object, IGroupingGetter<TModel>>> GroupBy<TModel>();
Type Parameters
TModel
The type of a model class that matches with the current DataObject.
Returns
System.Collections.Generic.IEnumerable<IGrouping<System.Object, PowerBuilder.Data.IGroupingGetter<TModel>>>
Returns an IEnumerable<IGrouping<Object,IGroupingGetter<TModel>>> 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 PowerBuilder.Data;
using System;
using System.Linq;
namespace Appeon.ApiDoc.IDataStoreExamples
{
public class GroupByExample
{
private SchoolContext _context;
public GroupByExample(SchoolContext dataContext)
{
// Sets the data context
_context = dataContext;
}
public void Example2()
{
// 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<D_Department_Course>();
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
Applies to
.NET Standard
2.x