static void Main(string[] args)
        {
            string cs = MSSqlConnectionProvider.GetConnectionString("localhost", "XpoSLExample");

            XpoDefault.DataLayer = XpoDefault.GetDataLayer(cs, AutoCreateOption.DatabaseAndSchema);
            XpoDefault.Session   = null;
            try {
                using (UnitOfWork uow = new UnitOfWork()) {
                    uow.UpdateSchema(typeof(Program).Assembly);
                    uow.CreateObjectTypeRecords(typeof(Program).Assembly);
                    Person p = uow.FindObject <Person>(null);
                    if (p == null)
                    {
                        new Person(uow)
                        {
                            FirstName = "Jake", LastName = "Smith", Birthdate = new DateTime(1990, 10, 1)
                        };
                        new Person(uow)
                        {
                            FirstName = "Bill", LastName = "Simpson", Birthdate = new DateTime(1982, 2, 20)
                        };
                        new Person(uow)
                        {
                            FirstName = "Harry", LastName = "Jonathan", Birthdate = new DateTime(1972, 5, 17)
                        };
                        uow.CommitChanges();
                    }
                    Console.WriteLine("Update successful.");
                }
            } catch (Exception) {
                Console.WriteLine("Update failed.");
            }
            Console.WriteLine("Press any key...");
            Console.ReadKey();
        }
Example #2
0
        public static void CreateSessions()
        {
            // generazione sequenziale dei GUID
            XpoDefault.GuidGenerationMode = GuidGenerationMode.UuidCreateSequential;

            //IDataStore store = XpoDefault.GetConnectionProvider("", AutoCreateOption.None);

            //XpoDefault.DataLayer = new SimpleDataLayer(store);

            XpoDefault.DataLayer = null;
            XpoDefault.Session   = null;

            var sex = new Session[2];

            IDataStore store1 = XpoDefault.GetConnectionProvider(MSSqlConnectionProvider.GetConnectionString(
                                                                     "192.168.0.20", "sa", "xxx", "MuseiXafRev1locale"), AutoCreateOption.None);

            IDataStore store2 = XpoDefault.GetConnectionProvider(MSSqlConnectionProvider.GetConnectionString(
                                                                     "192.168.0.30", "sa", "xxx", "MuseiXafRev1locale"), AutoCreateOption.None);

            sex[0] = new Session(new SimpleDataLayer(store1));
            sex[1] = new Session(new SimpleDataLayer(store2));

            Sessions = sex;
        }
        private void GetSalesRate()
        {
            try
            {
                string sqlquery = "";
                sqlquery = " select top 1 price from billdet where prodcode='" + Product.Code + "' and Custcode='" + SalesInvoice.Customer.ERPCode + "' order by bill_date desc";
                //Initialize your data layer.
                //By default if you don't do this, XPO will try and use an access databse (jet)
                Session session = new Session();
                XpoDefault.DataLayer = XpoDefault.GetDataLayer(MSSqlConnectionProvider.GetConnectionString(SalesInvoice.Company.ServerName, SalesInvoice.Company.ERPMasterDB + SalesInvoice.Company.Initials), AutoCreateOption.None);
                //XpoDefault.DataLayer = XpoDefault.GetDataLayer(MSSqlConnectionProvider.GetConnectionString("ACC00", SalesInvoice.Company.ERPMasterDB + SalesInvoice.Company.Initials), AutoCreateOption.None);
                XpoDefault.Session = session;

                //Equivalent of SELECT * FROM TableName in SQL
                // YourClassName would be your XPO object (your persistent object)
                using (var uow = new UnitOfWork())
                {
                    SelectedData sd = uow.ExecuteQuery(sqlquery);


                    foreach (var item in sd.ResultSet)
                    {
                        Price = Convert.ToDecimal(item.Rows[0].Values[0]);
                    }
                }
            }
            catch (Exception ex) { }
        }
        static void Main()
        {
            string conn = MSSqlConnectionProvider.GetConnectionString("(local)", "Northwind");

            XpoDefault.DataLayer = XpoDefault.GetDataLayer(conn, AutoCreateOption.None);
            Application.Run(new Form1());
        }
        static IDataLayer SetupDB1()
        {
            string       connString = MSSqlConnectionProvider.GetConnectionString("(local)", "SampleDB1");
            XPDictionary dict       = new ReflectionDictionary();

            dict.CollectClassInfos(typeof(Contact));
            IDataLayer dal = XpoDefault.GetDataLayer(connString, dict, AutoCreateOption.DatabaseAndSchema);

            using (UnitOfWork uow = new UnitOfWork(dal)) {
                uow.UpdateSchema(typeof(Contact));
                if (uow.FindObject <Contact>(null) == null)
                {
                    Contact contact1 = new Contact(uow)
                    {
                        FirstName = "John", LastName = "Doe"
                    };
                    Contact contact2 = new Contact(uow)
                    {
                        FirstName = "Paul", LastName = "Smith"
                    };
                    uow.CommitChanges();
                }
            }
            return(dal);
        }
Example #6
0
        static void Main(string[] args)
        {
            XpoDefault.DataLayer = XpoDefault.GetDataLayer(
                MSSqlConnectionProvider.GetConnectionString("(localdb)\\mssqllocaldb", "ModifyXPQueryTest"),
                AutoCreateOption.DatabaseAndSchema);

            CreateTestData();

            using (var uow = new UnitOfWork()) {
                // This works - obviously
                //var data = CollectionData(uow);

                // This also works - returning data from an XPQuery, but without projection
                var data = QueryDataFullObjects(uow);

                // This wouldn't work - if the type is not Person, I couldn't modify it
                // var data = QueryDataPartialObjects(uow);

                ModifyObjects(data);

                uow.CommitChanges();
            }

            OutputData();
        }
Example #7
0
        public MainForm()
        {
            InitializeComponent();

            #if USE_DB
            XpoDefault.ConnectionString = MSSqlConnectionProvider.GetConnectionString(".", "sa", "123", "testdb");

                #if USE_SESSION
            _session = new Session();
                #else
            _unitOfWork = new UnitOfWork();
                #endif
            #endif

            var classInfo =
                #if USE_SESSION
                _session
                #else
                _unitOfWork
                #endif
                .GetClassInfo <TestDetail>();

            var memberInfo = classInfo.GetMember(nameof(TestDetail.MasterVal));
            Debug.WriteLine(memberInfo.IsReadOnly);

            gridControl.DataSource = DataSource;

            //gridView.OptionsSelection.UseIndicatorForSelection = false;

            InitializeComponentWithFilter();
            InitializeComponentWithValidation();
        }
Example #8
0
        /// <summary>
        /// It does load database connection.
        /// </summary>
        public static void LoadingDatabaseConnection()
        {
            try {
                // Database connection string properties.
                var server     = @"ALBERTO-PC\SQL";
                var dbUser     = "******";
                var dbPassword = "******";
                var dbName     = "XpoTestDatabase";

                // It does create the database connection and bring back the unit of work that will be used.
                var connection     = MSSqlConnectionProvider.GetConnectionString(server, dbUser, dbPassword, dbName);
                var dataLayerLocal = XpoDefault.GetDataLayer(connection, AutoCreateOption.DatabaseAndSchema);
                var unitOfWork     = new UnitOfWork(dataLayerLocal);

                unitOfWork.Connect();

                // It does update database structure.
                unitOfWork.UpdateSchema();

                // It does create a new user.
                var user = new User(unitOfWork);
                user.UserName = "******";
                user.Password = "******";

                // It does persist new user data in datbase.
                unitOfWork.CommitChanges();
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);
            }
        }
Example #9
0
    private static IDataLayer GetDataLayer()
    {
        // set XpoDefault.Session to null to prevent accidental use of XPO default session
        XpoDefault.Session = null;

        string       conn = MSSqlConnectionProvider.GetConnectionString("(local)", "XpoWebTest");
        XPDictionary dict = new ReflectionDictionary();

        /* Note: The database schema must exactly match your persistent classes' definition. ASP.NET applications
         * should not update the database schema themselves; moreover, they often don't have enough permission
         * to read the database schema.  You may need to create a separate tool which manages your database.
         * On the one hand, we recommend using AutoCreateOption.SchemaAlreadyExists for the XPO data layer of your
         * Web site.  On the other hand, the ThreadSafeDataLayer intensively uses data which is stored in the XPO's
         * XPObjectType service table.  This sample project maps to the XpoWebTest database on your MS SQL Server.
         * This database is created via the DatabaseUpdater project, which must be launched before this Site is
         * published. */

        IDataStore store = XpoDefault.GetConnectionProvider(conn, AutoCreateOption.SchemaAlreadyExists);

        // initialize the XPO dictionary
        dict.GetDataStoreSchema(typeof(PersistentObjects.Customer).Assembly);

        // create a ThreadSafeDataLayer
        IDataLayer dl = new ThreadSafeDataLayer(dict, store);

        return(dl);
    }
Example #10
0
        public static IDataLayer GetDataLayer()
        {
            XpoDefault.Session = null;
            var uow           = XpoHelper.GetNewUnitOfWork();
            var sqlConnection = uow.FindObject <SQLConnection>(CriteriaOperator.Parse("Oid==?", 1));
            //string conn = MySqlConnectionProvider.GetConnectionString("localhost", "root", "", "CUFE");
            string sqlConnectionString = MSSqlConnectionProvider.GetConnectionString(sqlConnection.IP, sqlConnection.user, sqlConnection.password, sqlConnection.Datenbank);
            //string conn = System.Configuration.ConfigurationManager.ConnectionStrings[sqlConnectionString].ConnectionString;
            XPDictionary dict  = new ReflectionDictionary();
            IDataStore   store = XpoDefault.GetConnectionProvider(sqlConnectionString, AutoCreateOption.None);

            //DevExpress.Xpo.Metadata.ReflectionClassInfo.SuppressSuspiciousMemberInheritanceCheck = true;
            //dict.GetDataStoreSchema(typeof(Inscripcion).Assembly);
            //IDataLayer dl = new ThreadSafeDataLayer(dict, store);
            ////using (UnitOfWork uow = new UnitOfWork(dl))
            ////{
            ////    int cnt = (int)uow.Evaluate<CUFE.Models.Country>(CriteriaOperator.Parse("count"), null);
            ////    if (cnt == 0)
            ////    {
            ////        new CUFE.Models.Country(uow) { CountryName = "Germany" };
            ////        uow.CommitChanges();
            ////    }
            ////}
            //return dl;

            return(XpoDefault.GetDataLayer(sqlConnectionString, AutoCreateOption.SchemaAlreadyExists));
        }
Example #11
0
        public MainForm()
        {
            InitializeComponent();

            XpoDefault.ConnectionString = MSSqlConnectionProvider.GetConnectionString(".", "sa", "123", "testdb");

            _dataSet = GenerateDataSet();

            SetDataSource(_dataSet.Tables[TableNameWithMainData]);

            gridView.OptionsBehavior.EditorShowMode = EditorShowMode.MouseDown; // https://www.devexpress.com/Support/Center/Question/Details/Q295448 In order to edit checkbox column 2 click is needed, how do I get around that?

            gridView.Columns[FieldNameWithLookUp].ColumnEdit     = CreateLookUpEditor();
            gridView.Columns[FieldNameWithGridLookUp].ColumnEdit = CreateGridLookUpEditor();
            gridView.BestFitColumns();

            gridView.ShowingEditor += GridView_ShowingEditor;
            gridView.ShownEditor   += GridView_ShownEditor;

            gridView.CellValueChanging += GridView_CellValueChanging;
            gridView.CellValueChanged  += GridView_CellValueChanged;

            gridView.HiddenEditor += GridView_HiddenEditor;

            gridView.CustomRowCellEditForEditing += GridView_CustomRowCellEditForEditing;
            gridView.CustomRowCellEdit           += GridView_CustomRowCellEdit;

            gridControlMasterDetail.DataSource = new XPCollection <TestMaster>();
            //gridViewMasterDetail.OptionsBehavior.EditorShowMode = EditorShowMode.Default;
        }
Example #12
0
        private XPObjectSpaceProvider CreateObjectSpaceProvider()
        {
            MSSqlClientHelper.DropDatabase(ServerName, DatabaseName);
            MSSqlClientHelper.CreateDatabase(ServerName, DatabaseName, DataPath);
            string connectionString = MSSqlConnectionProvider.GetConnectionString(ServerName, DatabaseName);

            return(new XPObjectSpaceProvider(connectionString, null));
        }
Example #13
0
        static void Main()
        {
            string conn = MSSqlConnectionProvider.GetConnectionString("(local)", "Northwind");

            XpoDefault.DataLayer = XpoDefault.GetDataLayer(conn, AutoCreateOption.SchemaAlreadyExists);
            XpoDefault.Session.Dictionary.CollectClassInfos(typeof(Customer).Assembly);
            Application.Run(new Form1());
        }
Example #14
0
        static Service1()
        {
            string        connectionString = MSSqlConnectionProvider.GetConnectionString("localhost", "ServiceDB");
            IDataStore    dataStore        = XpoDefault.GetConnectionProvider(connectionString, AutoCreateOption.DatabaseAndSchema);
            DataCacheRoot dataCacheRoot    = new DataCacheRoot(dataStore);

            dataCacheRoot.Configure(new DataCacheConfiguration(DataCacheConfigurationCaching.InList, "Customer"));
            MainDataStore = dataCacheRoot;
        }
 private void xpInstantFeedbackSource1_ResolveSession(object sender, ResolveSessionEventArgs e)
 {
     session1 = new Session()
     {
         ConnectionString = MSSqlConnectionProvider.GetConnectionString("(local)", "NorthWind")
     };
     session1.Connect();
     e.Session = session1;
 }
Example #16
0
        static void Main()
        {
            string connectionStr = MSSqlConnectionProvider.GetConnectionString("(local)", "Northwind");

            XpoDefault.DataLayer = XpoDefault.GetDataLayer(connectionStr, AutoCreateOption.DatabaseAndSchema);
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }
        static Service1()
        {
            string       connectionString = MSSqlConnectionProvider.GetConnectionString("localhost", "ServiceDB");
            IDataStore   dataStore        = XpoDefault.GetConnectionProvider(connectionString, AutoCreateOption.DatabaseAndSchema);
            XPDictionary dictionary       = new ReflectionDictionary();

            dictionary.CollectClassInfos(typeof(Customer).Assembly);
            XpoDefault.DataLayer = new ThreadSafeDataLayer(dictionary, dataStore);
            XpoDefault.Session   = null;
        }
Example #18
0
        static void Main()
        {
            string connectionString = MSSqlConnectionProvider.GetConnectionString(@"(local)", "Customers");

            XpoDefault.DataLayer = XpoDefault.GetDataLayer(connectionString, DevExpress.Xpo.DB.AutoCreateOption.DatabaseAndSchema);
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            CreateTable();
            Application.Run(new Form1());
        }
    private static IDataLayer GetDataLayer()
    {
        XpoDefault.Session = null;
        XPDictionary dict = new ReflectionDictionary();

        dict.GetDataStoreSchema(typeof(Person).Assembly, typeof(bi.AuditDataItemPersistent).Assembly, typeof(AuditDataItem).Assembly);
        return(new ThreadSafeDataLayer(dict,
                                       XpoDefault.GetConnectionProvider(MSSqlConnectionProvider.GetConnectionString("(local)", "Q295139"),
                                                                        AutoCreateOption.DatabaseAndSchema)));
    }
Example #20
0
    private static IDataLayer GetDataLayer()
    {
        XpoDefault.Session = null;
        XPDictionary dict = new ReflectionDictionary();

        dict.GetDataStoreSchema(typeof(Category).Assembly);
        return(new ThreadSafeDataLayer(dict,
                                       XpoDefault.GetConnectionProvider(MSSqlConnectionProvider.GetConnectionString("(local)", "Northwind"),
                                                                        AutoCreateOption.None)));
    }
Example #21
0
        public MainForm()
        {
            InitializeComponent();

            XpoDefault.ConnectionString = MSSqlConnectionProvider.GetConnectionString("i-nozhenko", "sa", "123", "testdb");

            _session = new Session();
            gridControl.DataSource = new XPServerCollectionSource(_session, _session.GetClassInfo(typeof(TestDE)));
            //((XPServerCollectionSource)gridControl.DataSource).TrackChanges = true;
        }
Example #22
0
        private static IDataLayer GetDataLayer()
        {
            XpoDefault.Session = null;
            string conn = MSSqlConnectionProvider.GetConnectionString(resources.api.cdsonline.co.za.Properties.Settings.Default.Server.ToString(), resources.api.cdsonline.co.za.Properties.Settings.Default.DB.ToString());
            //XPDictionary dict = new ReflectionDictionary();
            IDataStore store = XpoDefault.GetConnectionProvider(conn, AutoCreateOption.SchemaAlreadyExists);
            //dict.GetDataStoreSchema(typeof(PersistentObjects.Customer).Assembly);
            IDataLayer dl = new SimpleDataLayer(store); //new ThreadSafeDataLayer(dict, store);

            return(dl);
        }
Example #23
0
        private static void StartConnectionConfigDb()
        {
            // Retrieve the Data Store specific connection string.
            string connectionString  = MSSqlConnectionProvider.GetConnectionString(@"DBSRV\QWERTY", @"user02", @"8a0IucJ@Nx1Qy5HfFrX0Ob3m", @"Sales");
            string connectionString1 = SQLiteConnectionProvider.GetConnectionString(@"D:\TEMP\SQLite\SQLITEDB1.db3");
            //
            IDataLayer dataLayer = XpoDefault.GetDataLayer(connectionString1, AutoCreateOption.DatabaseAndSchema);

            XpoDefault.DataLayer = dataLayer;
            //Session session = new Session();
        }
Example #24
0
 public static string GetConnectionString(bool isOnline)
 {
     if (isOnline)
     {
         return(ConfigurationManagerEx.UserName.Length > 0 ? MSSqlConnectionProvider.GetConnectionString(ConfigurationManagerEx.ServerName, ConfigurationManagerEx.UserName, ConfigurationManagerEx.Password, ConfigurationManagerEx.DatabaseName) : MSSqlConnectionProvider.GetConnectionString(ConfigurationManagerEx.ServerName, ConfigurationManagerEx.DatabaseName));
     }
     else
     {
         return(ConfigurationManagerEx.OfflineUserName.Length > 0 ? MSSqlConnectionProvider.GetConnectionString(ConfigurationManagerEx.OfflineServerName, ConfigurationManagerEx.OfflineUserName, ConfigurationManagerEx.OfflinePassword, ConfigurationManagerEx.OfflineDatabaseName) : MSSqlConnectionProvider.GetConnectionString(ConfigurationManagerEx.OfflineServerName, ConfigurationManagerEx.OfflineDatabaseName));
     }
 }
        static void Main()
        {
            XPBaseObject.AutoSaveOnEndEdit = false;
            string            conn          = MSSqlConnectionProvider.GetConnectionString("(local)", "AdventureWorks");
            ReadOnlyDataStore readOnlyStore = new ReadOnlyDataStore(XpoDefault.GetConnectionProvider(conn, AutoCreateOption.SchemaAlreadyExists));

            XpoDefault.DataLayer = new SimpleDataLayer(readOnlyStore);

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }
Example #26
0
        private static void DBSetup()
        {
            XpoDefault.GuidGenerationMode = GuidGenerationMode.UuidCreateSequential;

            string conn = MSSqlConnectionProvider.GetConnectionString("hde01", "sa", "xxx", "MuseiXafTest1");

            IDataStore store = XpoDefault.GetConnectionProvider(conn, AutoCreateOption.None);

            XpoDefault.DataLayer = new SimpleDataLayer(store);

            XpoDefault.Session = null;
        }
Example #27
0
        private void Generation_Execute(object sender, SimpleActionExecuteEventArgs e)
        {
            string connectionString = MSSqlConnectionProvider.GetConnectionString("ART-LAPTOP\\SQLEXPRESS", "TestEx2");

            XpoDefault.DataLayer = XpoDefault.GetDataLayer(connectionString, AutoCreateOption.DatabaseAndSchema);
            Session session = new Session();

            for (int i = 1; i < 101; i++)
            {
                Airport a = new Airport(session);
                a.NameOfAirport = "Аэропорт " + i.ToString();
                Pilot b = new Pilot(session);
                b.Name = "Пилот " + i.ToString() + "0";
                Pilot c = new Pilot(session);
                c.Name = "Пилот " + i.ToString() + "1";
                Plane d = new Plane(session);
                d.NameOfPlane = "Самолет " + i.ToString() + "0";
                Plane f = new Plane(session);
                f.NameOfPlane = "Самолет " + i.ToString() + "1";
                Plane g = new Plane(session);
                g.NameOfPlane = "Самолет " + i.ToString() + "2";
                Plane h = new Plane(session);
                h.NameOfPlane = "Самолет " + i.ToString() + "3";
                Plane j = new Plane(session);
                j.NameOfPlane = "Самолет " + i.ToString() + "4";
                b.OwnPlane.Add(d);
                b.AllowedPlanes.Add(f);
                b.AllowedPlanes.Add(g);
                c.OwnPlane.Add(h);
                c.OwnPlane.Add(j);
                c.AllowedPlanes.Add(f);
                c.AllowedPlanes.Add(g);
                c.AllowedPlanes.Add(d);

                b.Airport = a;
                c.Airport = a;
                d.Airport = a;
                f.Airport = a;
                g.Airport = a;
                h.Airport = a;
                j.Airport = a;

                a.Save();
                b.Save();
                c.Save();
                d.Save();
                f.Save();
                g.Save();
                h.Save();
                j.Save();
            }
            //session.ClearDatabase();
        }
        static IDataLayer SetupDB2()
        {
            string       connString = MSSqlConnectionProvider.GetConnectionString("(local)", "SampleDB2");
            XPDictionary dict       = new ReflectionDictionary();

            dict.CollectClassInfos(typeof(Task));
            IDataLayer dal = XpoDefault.GetDataLayer(connString, dict, AutoCreateOption.DatabaseAndSchema);

            using (UnitOfWork uow = new UnitOfWork(dal)) {
                uow.UpdateSchema(typeof(Task));
            }
            return(dal);
        }
Example #29
0
        public static bool VerifyConnections(string ServerName, string DBName)
        {
            try
            {
                DevExpress.Xpo.XpoDefault.GetDataLayer(MSSqlConnectionProvider.GetConnectionString(ServerName, DBName), AutoCreateOption.None);
            }
            catch (UnableToOpenDatabaseException ex)
            {
                return(false);
            }

            return(true);
        }
Example #30
0
        static void Main(string[] args)
        {
            try
            {
                //DevExpress.Xpo.Metadata.ReflectionClassInfo.SuppressSuspiciousMemberInheritanceCheck = true;

                XpoDefault.ConnectionString = MSSqlConnectionProvider.GetConnectionString(".", "sa", "123", "testdb");

                using (var session = new UnitOfWork())
                {
                    object tmpObject;

                    var person = new Person(session);
                    person.Id   = (tmpObject = session.ExecuteScalar("select max(Id) + 1 from Person")) != null && !Convert.IsDBNull(tmpObject) ? Convert.ToInt32(tmpObject) : 1;
                    person.Name = "Person";
                    session.Save(person);
                    session.CommitChanges();

                    var employee = new Employee(session);
                    employee.Id     = (tmpObject = session.ExecuteScalar("select max(Id) + 1 from Person")) != null && !Convert.IsDBNull(tmpObject) ? Convert.ToInt32(tmpObject) : 1;
                    employee.Name   = "Employee";
                    employee.Salary = 123;

                    person = session.GetObjectByKey <Person>(employee.Id);
                    var employee2 = session.GetObjectByKey <Employee>(employee.Id);
                    session.Save(employee);
                    person    = session.GetObjectByKey <Person>(employee.Id);
                    employee2 = session.GetObjectByKey <Employee>(employee.Id);
                    session.CommitChanges();

                    var executive = new Executive(session);
                    executive.Id     = (tmpObject = session.ExecuteScalar("select max(Id) + 1 from Person")) != null && !Convert.IsDBNull(tmpObject) ? Convert.ToInt32(tmpObject) : 1;
                    executive.Name   = "Executive";
                    executive.Salary = 456;
                    executive.Bonus  = 789;
                    session.Save(executive);
                    session.CommitChanges();

                    var customer = new Customer(session);
                    customer.Id          = (tmpObject = session.ExecuteScalar("select max(Id) + 1 from Person")) != null && !Convert.IsDBNull(tmpObject) ? Convert.ToInt32(tmpObject) : 1;
                    customer.Name        = "Customer";
                    customer.Preferences = "Preferences";
                    session.Save(customer);
                    session.CommitChanges();
                }
            }
            catch (Exception eException)
            {
                Console.WriteLine(eException.GetType().FullName + Environment.NewLine + "Message: " + eException.Message + Environment.NewLine + (eException.InnerException != null && !string.IsNullOrEmpty(eException.InnerException.Message) ? "InnerException.Message" + eException.InnerException.Message + Environment.NewLine : string.Empty) + "StackTrace:" + Environment.NewLine + eException.StackTrace);
            }
        }