You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: designing-reports/connecting-to-data/data-source-components/entitycoredatasource-component/configuring-the-database-connectivity-with-the-entitycoredatasource-component.md
+5-35Lines changed: 5 additions & 35 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,46 +20,16 @@ A typical EF Core `DbContext` reads its connection string from `appsettings.json
20
20
21
21
To overcome this, the `EntityCoreDataSource` component exposes a `ConnectionString` property. When configuring the data source in the Web Report Designer or the Standalone Report Designer, the wizard prompts for the connection string and stores it in the report definition. At processing time, the component forwards the value to the `DbContext` constructor that accepts a `string` argument at processing time. The `DbContext` must therefore expose such a constructor, as shown in the following Code First sample:
The wizard stores the value as an attribute on the `EntityCoreDataSource` element of the `.trdp` or `.trdx` definition. To centralize the value and avoid embedding credentials in the file, use a named connection instead. Store it in the configuration file of the report-hosting process and read it at startup before assigning it to the `ConnectionString` property.
Copy file name to clipboardExpand all lines: designing-reports/connecting-to-data/data-source-components/entitycoredatasource-component/connecting-to-a-dbcontext-with-the-entitycoredatasource-component.md
To create the simplest configuration, use the parameterless constructor and set the `Context` and `ContextMember` properties. Set `Context` to the `DbContext` type and `ContextMember` to the name of the `DbSet<T>`, queryable property, or method that retrieves the data:
@@ -62,17 +51,7 @@ The `Context` property is typed as `object` and accepts either a `Type` referenc
62
51
- When you supply a **type**, the component instantiates the `DbContext`, holds it for the duration of report processing, and disposes it automatically. This is the recommended pattern because it preserves [lazy loading](slug:entitycoredatasource-context-lifecycle) throughout report processing.
63
52
- When you supply an **instance**, the application owns the lifetime of the context. The component does not call `Dispose` on the supplied instance.
Copy file name to clipboardExpand all lines: designing-reports/connecting-to-data/data-source-components/entitycoredatasource-component/maintaining-the-lifecycle-of-the-context-with-the-entitycoredatasource-component.md
+2-20Lines changed: 2 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -30,31 +30,13 @@ When you assign a `Type` to the `Context` property (or pass one to the construct
30
30
1. The instance is held for the duration of report processing so that lazy-loaded navigation properties remain available.
31
31
1. The component disposes the instance when rendering completes.
When you assign a live `DbContext` instance to the `Context` property, the application is responsible for disposing it. The component does not call `Dispose` on a context it did not create. Use this pattern when the context is wired into your application's dependency-injection container and must follow the container's scope.
> warning Disposing the supplied `DbContext` before the report engine finishes processing the report breaks lazy loading and causes runtime exceptions. Coordinate the dispose call with the end of the report-processing pipeline.
Copy file name to clipboardExpand all lines: designing-reports/connecting-to-data/data-source-components/entitycoredatasource-component/using-parameters-with-the-entitycoredatasource-component.md
+3-21Lines changed: 3 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,35 +20,17 @@ This article explains how to pass values from [Report Parameters](slug:telerikre
20
20
21
21
Add a method or queryable property on the `DbContext` that accepts the values you need to filter by. The names and types of the data source parameters must match the names and types of the corresponding method arguments exactly; otherwise the component throws an exception at runtime.
Set the `ContextMember` property to the method name and add one entry to the `Parameters` collection of the data source for every method argument. The `Parameters` collection is inherited through `ObjectDataSourceBase` and exposes the same fluent overload used by every Telerik Reporting data source: `Add(name, type, valueOrExpression)`. Bind to a [Report Parameter](slug:telerikreporting/designing-reports/connecting-to-data/report-parameters/overview) by setting the value to an expression such as `=Parameters.threshold.Value`:
Another option is a custom implementation of the [IConfiguration](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.configuration.iconfiguration) interface.
0 commit comments