Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
LINQ Reporting Engine enables you to perform common manipulations on a sequential data through the engine’s built-in extension methods for Iterable. 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 common 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 Comparable.EnumerationSelector stands for Selector returning Iterable.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.
public class Person
{
public String getName() { ... }
public int getAge() { ... }
public Iterable<Person> getChildren() { ... }
...
}
| Extension Method | Examples and Notes |
|---|---|
all(Predicate) |
|
any() |
|
any(Predicate) |
|
average(Selector) |
|
concat(Iterable) |
|
contains(Object) |
|
count() |
|
count(Predicate) |
|
distinct() |
|
elementAt(int) |
|
elementAtOrDefault(int) |
|
first() |
|
first(Predicate) |
|
firstOrDefault() |
|
firstOrDefault(Predicate) |
|
groupBy(Selector) |
Key field. You can treat a group itself as an enumeration of items that the group contains. |
last() |
|
last(Predicate) |
|
lastOrDefault() |
|
lastOrDefault(Predicate) |
|
max(ComparableSelector) |
|
min(ComparableSelector) |
|
orderBy(ComparableSelector) |
- thenBy(ComparableSelector) - thenByDescending(ComparableSelector) |
orderByDescending(ComparableSelector) |
|
select(Selector) |
|
selectMany(EnumerationSelector) |
|
single() |
|
single(Predicate) |
|
singleOrDefault() |
|
singleOrDefault(Predicate) |
|
skip(int) |
|
skipWhile(Predicate) |
|
sum(Selector) |
|
take(int) |
|
takeWhile(Predicate) |
|
union(Iterable) |
|
where(Predicate) |
|
Q: How can I obtain the index of the current item inside a foreach loop in a template?
A: Use the built‑in index variable that the LINQ Reporting Engine provides for each iteration. Inside the foreach tag you can write <<#= index>> to output the zero‑based position of the current element.
Q: Is there a way to access the previous element while iterating over a collection?
A: The engine does not expose a direct previous() method. A common workaround is to use skip(1) together with first() on a sliced collection, e.g., persons.skip(1).first() gives the element after the first one, which you can compare with the current index.
Q: How do I group items by a calculated key, such as age, and then iterate over each group?
A: Use the groupBy extension method. Example: persons.groupBy(p => p.getAge()) returns a collection of groups. Inside the template you can iterate: <<foreach [group in persons.groupBy(p => p.getAge())]>> Age: <<group.Key>> Count: <<group.count()>> <<endforeach>>.
Q: What extension methods should I use to sort a collection by multiple fields?
A: First apply orderBy (or orderByDescending) with the primary key, then chain thenBy or thenByDescending for secondary keys. Example: persons.orderBy(p => p.getAge()).thenByDescending(p => p.getName()).thenBy(p => p.getChildren().count()).
Q: How can I check whether any element in a collection satisfies a condition?
A: Use the any(Predicate) method. Example: persons.any(p => p.getAge() > 65) returns true if at least one person is older than 65, otherwise false.
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.