LINQ Reporting Engine enables you to perform common manipulations on a sequential data through the engine’s built-in extension methods for IEnumerable. These extension methods mimic some extension methods of IEnumerable<T> providing the same signatures and behavior features. Thus you can group, sort and perform other sequential data manipulations in template expressions in a familiar way.
The following table describes these built-in extension methods. The following notation conventions are used within the table:
Selector stands for a lambda function returning a value and taking an enumeration item as its single argument. See “Using Lambda Functions” for more information.
ComparableSelector stands for Selector returning IComparable.
EnumerationSelector stands for Selector returning IEnumerable.
Predicate stands for Selector returning a Boolean value.
Examples in the following table are given using persons and otherPersons, enumerations of instances of the Person class that is defined as follows.
This method returns an enumeration of group objects. Each group has a unique key defined by the input selector and contains items of the source enumeration associated with this key. You can access the key of a group instance using the Key property. You can treat a group itself as an enumeration of items that the group contains. Keys are compared as described in Comparing Keys of GroupBy and Distinct.
This method returns an enumeration ordered by a single key. To specify additional ordering keys, you can use the following extension methods of an ordered enumeration:- ThenBy(ComparableSelector)- ThenByDescending(ComparableSelector)
The input selector must return a value of any type that has a predefined or user-defined addition operator.
Take(int)
persons.Take(5)
TakeWhile(Predicate)
persons.TakeWhile(p=>p.Age<50)
Union(IEnumerable)
persons.Union(otherPersons)
An implicit reference conversion must exist between types of items of united enumerations.
Where(Predicate)
persons.Where(p=>p.Age>18)
Predicates over Nullable Boolean Values
Note
This feature is supported by version 26.11 or greater.
Boolean values of JSON, XML and CSV data, and bool? members of your own classes, are nullable because the value may be missing. Such values can be returned by a Predicate directly, without == true. A missing value counts as false.
Done: <<[tasks.Count(t => t.Done)]>> of <<[tasks.Count()]>>
Not done: <<foreach [t in tasks.Where(t => t.Done != true)]>><<[t.Title]>>; <</foreach>>
All done: <<[tasks.All(t => t.Done)]>>
The result will be like:
Done: 1 of 3
Not done: Clean grinder; Call supplier;
All done: False
Warning
A negation of a missing value is missing as well, so tasks.Where(t => !t.Done) returns the tasks with false only. To include missing values, compare with true: t.Done != true.
Comparing Keys of GroupBy and Distinct
Note
This feature is supported by version 26.11 or greater.
GroupBy and Distinct compare keys and items depending on where they come from:
Nested objects of JSON and XML data are compared by value, including their own nested objects: {"Name":"A"} and {"Name":"A"} make one group. Objects of JSON data with different $id values are different objects, even if their values are equal.
Rows of a DataSet of your own are compared by identity: orders of the same customer row make one group, while two customer rows with equal values stay two groups.
Objects of your own classes are compared as .NET does it, using their Equals and GetHashCode methods.
To group by a value rather than by an object, use a simple key, such as GroupBy(o => o.Customer.Name).
For example, orders 1 and 3 below hold equal customer objects:
{"Orders":[{"Number":1,"Paid":true,"Customer":{"Name":"Quayside Bistro"}},{"Number":2,"Paid":false,"Customer":{"Name":"Harbor Lane Provisions"}},{"Number":3,"Paid":null,"Customer":{"Name":"Quayside Bistro"}}]}