Back to Devexpress

ThreadSafeDataLayer(XPDictionary, IDataStore, Assembly[]) Constructor

xpo-devexpress-dot-xpo-dot-threadsafedatalayer-dot-ctor-x28-devexpress-dot-xpo-dot-metadata-dot-xpdictionary-devexpress-dot-xpo-dot-db-dot-idatastore-system-dot-reflection-dot-assembly-x29.md

latest3.6 KB
Original Source

ThreadSafeDataLayer(XPDictionary, IDataStore, Assembly[]) Constructor

Initializes a new instance of the ThreadSafeDataLayer class.

Namespace : DevExpress.Xpo

Assembly : DevExpress.Xpo.v25.2.dll

NuGet Package : DevExpress.Xpo

Declaration

csharp
public ThreadSafeDataLayer(
    XPDictionary dictionary,
    IDataStore provider,
    params Assembly[] assemblies
)
vb
Public Sub New(
    dictionary As XPDictionary,
    provider As IDataStore,
    ParamArray assemblies As Assembly()
)

Parameters

NameTypeDescription
dictionaryXPDictionary

An XPDictionary object that specifies the metadata.

| | provider | IDataStore |

A IDataStore object which implements data-specific functionality.

| | assemblies | Assembly[] |

An array of persistent object assemblies.

|

Example

The following code demonstrates how to initialize the ThreadSafeDataLayer component. The XPDictionary.GetDataStoreSchema method is called to force creating the persistent class metadata information in advance. This is a required step.

The XPDictionary.GetDataStoreSchema method allows you to specify the array of class types or assemblies where persistent classes are declared. In this example, it is assumed that all persistent classes are declared in the assembly that contains the code that is currently being executed.

csharp
private static IDataLayer GetDataLayer() {
   XpoDefault.Session = null;
   string conn = ConfigurationManager.ConnectionStrings["ConnectionStringName"].ConnectionString;
   conn = XpoDefault.GetConnectionPoolString(conn);
   XPDictionary dict = new ReflectionDictionary();
   IDataStore store = XpoDefault.GetConnectionProvider(conn, AutoCreateOption.SchemaAlreadyExists);
    dict.GetDataStoreSchema(System.Reflection.Assembly.GetExecutingAssembly());
   IDataLayer dl = new ThreadSafeDataLayer(dict, store);
   return dl;
}
vb
Private Shared Function GetDataLayer() As IDataLayer
   XpoDefault.Session = Nothing
   Dim conn As String = ConfigurationManager.ConnectionStrings("ConnectionStringName").ConnectionString
   conn = XpoDefault.GetConnectionPoolString(conn)
   Dim dict As XPDictionary = New ReflectionDictionary()
   Dim store As IDataStore = XpoDefault.GetConnectionProvider(conn, AutoCreateOption.SchemaAlreadyExists)
    dict.GetDataStoreSchema(System.Reflection.Assembly.GetExecutingAssembly())
   Dim dl As IDataLayer = New ThreadSafeDataLayer(dict, store)
   Return dl
End Function

See Also

ThreadSafeDataLayer Class

ThreadSafeDataLayer Members

DevExpress.Xpo Namespace