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 access type members via LINQ when using Aspose.Words’s reporting engine.
LINQ Reporting Engine enables you to access the following public (static and instance) members of accessible types (see “Working with Types” for more information) in template expressions:
Note – To access a static member of a type in a template expression, the type must be set known for the engine (see “Setting up Known External Types” for more information).
A function type member can be used in a template expression only if the following additional requirements are met:
ref or out parameters.The engine supports the following features when dealing with function members:
In addition to C# Language features, the engine provides the following extra features to simplify type member access:
Q: How can I call a static method of a type in a template expression?
A: First register the type as a known external type with the reporting engine, e.g., engine.KnownTypes.Add(typeof(Math));. Then you can reference the static member directly in the template, such as Math::Sqrt(9). The :: syntax tells the engine to treat the left‑hand side as a type name.
Q: Do I need to specify the object name when accessing its instance properties?
A: No. The engine supports contextual object member access, allowing you to write just the property name (e.g., Name) when the current data object is the context. This simplifies templates and makes them more readable.
Q: What restrictions apply to methods used as function members in template expressions?
A: The method must return a value, cannot have ref or out parameters, and cannot be generic. Overload resolution follows the C# specification, default parameter values are supported, but named parameters are not.
Q: How can I safely access a member that might not exist on the data object?
A: Enable the engine’s missing‑member handling feature. When a member is not found, the engine returns null instead of throwing an exception, allowing you to write expressions like Customer?.PhoneNumber without errors.
Q: Is it possible to instantiate a type using its constructor in a template expression?
A: Yes. Constructors can be invoked as function members provided they meet the same rules (return value, no ref/out, no generics). Example: new DateTime(2023, 1, 1) creates a DateTime object that can be used directly in the expression.
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.