//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using DevExpress.Xpo;
using DevExpress.Data.Filtering;
using System.Collections.Generic;
using System.ComponentModel;
namespace Siegelportal.Module.BusinessObjects.Siegelportal
{
    public static class ConnectionHelper
    {
        static Type[] persistentTypes = new Type[] {
            typeof(Innung),
            typeof(SiegelBase),
            typeof(Kunde),
            typeof(Artikel),
            typeof(ArtikelInnungBezug),
            typeof(Verpackung),
            typeof(RolleBase),
            typeof(Rolle),
            typeof(Bogen),
            typeof(Lieferscheinkopf),
            typeof(Lieferscheinposition),
            typeof(Rechnungskopf),
            typeof(BewegungBase),
            typeof(Rechnungsposition),
            typeof(Retoure),
            typeof(Kolli),
            typeof(Lagerbewegung),
            typeof(Fehlnummer),
            typeof(WareneingangKopf),
            typeof(WareneingangPosition),
            typeof(OffeneBestellung)
        };
        public const string ConnectionString = @"XpoProvider=MSSqlServer;data source=VMSERVER;user id=sa;password=sa;initial catalog=Siegelportal;Persist Security Info=true";
        public static void Connect(DevExpress.Xpo.DB.AutoCreateOption autoCreateOption, bool threadSafe = false)
        {
            if (threadSafe)
            {
                var provider = XpoDefault.GetConnectionProvider(ConnectionString, autoCreateOption);
                var dictionary = new DevExpress.Xpo.Metadata.ReflectionDictionary();
                dictionary.GetDataStoreSchema(persistentTypes);
                XpoDefault.DataLayer = new ThreadSafeDataLayer(dictionary, provider);
            }
            XpoDefault.DataLayer = XpoDefault.GetDataLayer(ConnectionString, autoCreateOption);
            XpoDefault.Session = null;
        }
        public static DevExpress.Xpo.DB.IDataStore GetConnectionProvider(DevExpress.Xpo.DB.AutoCreateOption autoCreateOption)
        {
            return XpoDefault.GetConnectionProvider(ConnectionString, autoCreateOption);
        }
        public static DevExpress.Xpo.DB.IDataStore GetConnectionProvider(DevExpress.Xpo.DB.AutoCreateOption autoCreateOption, out IDisposable[] objectsToDisposeOnDisconnect)
        {
            return XpoDefault.GetConnectionProvider(ConnectionString, autoCreateOption, out objectsToDisposeOnDisconnect);
        }
        public static IDataLayer GetDataLayer(DevExpress.Xpo.DB.AutoCreateOption autoCreateOption)
        {
            return XpoDefault.GetDataLayer(ConnectionString, autoCreateOption);
        }
    }

}
