Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
What is this page about?
This page describes the enumeration extension methods available in Aspose.Words, helping to extend enum functionality.
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.
public class Person
{
public String Name { get { ... } }
public int Age { get { ... } }
public IEnumerable<Person> Children { get { ... } }
...
}
| Extension Method | Examples and Notes |
|---|---|
All(Predicate) |
|
Any() |
|
Any(Predicate) |
|
Average(Selector) |
|
Concat(IEnumerable) |
|
Contains(Object) |
|
Count() |
|
Count(Predicate) |
|
Distinct() |
|
ElementAt(int) |
|
ElementAtOrDefault(int) |
|
First() |
|
First(Predicate) |
|
FirstOrDefault() |
|
FirstOrDefault(Predicate) |
|
GroupBy(Selector) |
Key property. 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(IEnumerable) |
|
Where(Predicate) |
|
Q: How can I use the ElementAt extension method in a template expression?
A: Write the call directly in the template, e.g., persons.ElementAt(3), to obtain the fourth element (zero‑based indexing). Ensure the source collection contains enough items; otherwise an ArgumentOutOfRangeException will be thrown.
Q: Can I chain multiple ordering methods such as OrderBy and ThenByDescending in a template?
A: Yes. After an OrderBy call you can append ThenBy or ThenByDescending to define secondary sort keys, for example persons.OrderBy(p => p.Age).ThenByDescending(p => p.Name).
Q: How do I filter a collection using the Where extension method in a report?
A: Use persons.Where(p => p.Age > 18) inside the template. The predicate must return a Boolean value, and the resulting filtered collection can be iterated or further processed with other extension methods.
Q: Is the GroupBy method supported for creating grouped sections in a template?
A: Yes. GroupBy returns groups that expose a Key property. In a template you can iterate over persons.GroupBy(p => p.Age), access each group’s Key, and then loop through the items belonging to that group.
Q: What should I do if an extension method is not recognized in my template?
A: Verify that the LINQ Reporting Engine is enabled and that the method name matches exactly one of the listed extension methods. Also confirm that the collection implements IEnumerable and that any required using directives are present in the template header.
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.