ThreadSafeDataLayer(XPDictionary, IDataStore, Assembly[]) Constructor
Initializes a new instance of the ThreadSafeDataLayer class.
Namespace: DevExpress.Xpo
Assembly: DevExpress.Xpo.v24.2.dll
Declaration
Parameters
Name | Type | Description |
---|---|---|
dictionary | XPDictionary | 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.
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;
}