Back to Devexpress

DataSourceBase.CreateObjectSpace(Type, IServiceProvider) Method

expressappframework-devexpress-dot-persistent-dot-base-dot-reportsv2-dot-datasourcebase-dot-createobjectspace-x28-system-dot-type-system-dot-iserviceprovider-x29.md

latest2.8 KB
Original Source

DataSourceBase.CreateObjectSpace(Type, IServiceProvider) Method

Creates an Object Space.

Namespace : DevExpress.Persistent.Base.ReportsV2

Assembly : DevExpress.Persistent.Base.v25.2.dll

NuGet Package : DevExpress.Persistent.Base

Declaration

csharp
public static IObjectSpace CreateObjectSpace(
    Type dataType,
    IServiceProvider serviceProvider
)
vb
Public Shared Function CreateObjectSpace(
    dataType As Type,
    serviceProvider As IServiceProvider
) As IObjectSpace

Parameters

NameTypeDescription
dataTypeType

A Type object that specifies the business object type for which the Object Space is retrieved.

| | serviceProvider | IServiceProvider |

An IServiceProvider object.

|

Returns

TypeDescription
IObjectSpace

An IObjectSpace object.

|

Remarks

To access data in an XAF application, you do not need to use an ORM-specific context or query data from the database directly. Instead of these techniques, use an Object Space’s methods (see Data Manipulation and Business Logic).

The CreateObjectSpace static method allows you to access an Object Space in report scripts:

csharp
private void report_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e) {
    DevExpress.ExpressApp.IObjectSpace objectSpace = 
        DevExpress.Persistent.Base.ReportsV2.DataSourceBase.CreateObjectSpace(typeof(MyObject), (DevExpress.XtraReports.UI.XtraReport)sender);
}

See Also

DataSourceBase Class

DataSourceBase Members

DevExpress.Persistent.Base.ReportsV2 Namespace