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 explains how to work with mail-merge data sources of various types.
LINQ Reporting Engine enables you to use a simplified syntax in template expressions to work with traditional Aspose.Words Mail Merge data source objects. See the following sections for more information.
LINQ Reporting Engine enables you to access DataTable objects contained within a particular DataSet instance by table names using the “.” operator in template expressions. That is, for example, given that ds is a DataSet instance that contains a DataTable named “Persons”, you can access the table using the following syntax.
ds.Persons
Note – Table names are case-insensitive.
LINQ Reporting Engine enables you to treat DataTable and DataView objects in template expressions as enumerations of their rows. That is, you can use template expressions evaluated to such objects in foreach tags (see “Outputting Sequential Data” for more information).
Also, you can normally apply enumeration extension methods (see “Appendix A. Enumeration Extension Methods” for more information) to DataTable and DataView objects in template expressions. For example, given that persons are a DataTable or DataView instance, you can count its rows using the following syntax.
persons.Count()
LINQ Reporting Engine enables you to access a data associated with a particular DataRow or DataRowView instance in template expressions using the “.” operator. The following table describes, which identifiers you can use to access different kinds of the data.
| Data Kind | Identifier | Examples of Template Expressions |
|---|---|---|
| Field Value | Field name | Given that r is a row that has a field named “Name”, you can access the field’s value using the following syntax. |
| Single Parent or Child Row | Parent (child) table name | Given that r is a row of a DataTable that has a parent (child) DataTable named “City”, you can access the single parent (child) row of r using the following syntax.Given that the “City” DataTable has a field named “Name”, you can access the field’s value for the single parent (child) row using the following syntax. |
| Enumeration of Child or Parent Rows | Child (parent) table name | Given that r is a row of a DataTable that has a child (parent) DataTable named “Persons”, you can access the enumeration of the child (parent) rows of r using the following syntax.Given that the “Persons” DataTable has a field named “Age”, you can count the child (parent) rows that correspond to persons over thirty years old using the following syntax. |
Note – Field and table names are case-insensitive.
To determine parent-child relationships for a particular DataTable instance, the engine uses DataRelation objects contained within the corresponding DataSet instance. Thus, you can manage these relationships in a common way.
Note – Instead of using of table names to access data of child or parent rows, you can also use relation names, which is useful when you deal with multiple relations to the same table.
LINQ Reporting Engine enables you to treat IDataReader implementors as enumerations of IDataRecord implementors in template expressions. That is, you can use IDataReader implementors in template expressions in the same way as DataTable objects. See “Working with DataTable and DataView Objects” for more information.
However, you can not use IDataReader implementors in template expressions in conjunction with enumeration operations that require a caching of enumeration items. Examples of such operations are grouping and sorting. To work around this restriction, use DataTable objects instead.
LINQ Reporting Engine enables you to access the field values of a particular IDataRecord implementor by field names using the “.” operator in template expressions. To use this feature, one of the following conditions must be met:
IDataRecord implementor represents an iteration variable upon enumerating an IDataReader implementor (see “Outputting Sequential Data” for more information).IDataRecord implementor does not implement the IDataReader interface.The following example shows, how to use this feature. Given that r is an IDataRecord implementor that has a field named “Name”, you can access the field’s value using the following syntax.
r.Name
Note – Field names are case‑insensitive.
Q: How can I reference a DataTable inside a DataSet from a template?
A: Use the dot operator with the table name, e.g., ds.Persons. Table names are case‑insensitive, and the DataSet instance must be passed to the reporting engine as a data source.
Q: Can I iterate over rows of a DataTable or DataView in a template?
A: Yes. Treat the DataTable/DataView as an enumerable and use a foreach tag. Inside the loop you can access each row via a variable (e.g., row) and use row.FieldName to get column values.
Q: How do I access parent or child rows from a DataRow in a template?
A: Use the parent or child table name after the row variable, e.g., row.City for a single related row or row.Persons for a collection of child rows. You can then chain further field accesses like row.City.Name.
Q: What if my data source uses IDataReader—can I still use LINQ Reporting Engine features like grouping?
A: IDataReader can be enumerated, but operations that require caching (grouping, sorting) are not supported. Convert the reader to a DataTable first if you need those features.
Q: How do I read a field from an IDataRecord inside a template?
A: Use the dot operator with the field name, e.g., record.Name. This works when the IDataRecord is the current iteration variable of an IDataReader enumeration or when it does not implement IDataReader.
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.