Пример #1
0
        static void Main(string[] args)
        {
               var dbConfig = new DbConfig()
               {
                   ConnectionString = @"Server=meng;Database=EasylinkWalkThrough;User Id=demo;Password=password;",
                   DatabaseType = DatabaseType.SqlServer,
                   SchemaName = "dbo"

               };

               DatabaseFactory.Initialize(dbConfig);


               var database = DatabaseFactory.Create();

                  database.ExecuteInTest(()=>
                  {
                      var employee = new Employee
                      {
                          FirstName = "Mark",
                          LastName = "Loren",
                          LoginId = "MLoren",
                          Active = true,
                          Role = new Lookup {Id = 2}
                          
                      };

                      //insert
                      database.Insert(employee);
                      Console.WriteLine("Employee is inserted!");
                      var employeeRetrieved = database.RetrieveObject<Employee>(e=>e.Id== employee.Id);
                      Console.WriteLine("Employee name: {0}", employeeRetrieved.FirstName);
                      Console.WriteLine("Employee Role: {0}", employeeRetrieved.Role.Name);

                      //update
                      employeeRetrieved.FirstName = "NewWorld";
                      database.Update(employeeRetrieved);
                      Console.WriteLine("Employee is updated!");
                      var employeeUpdated = database.RetrieveObject<Employee>(e=>e.Id== employee.Id);
                      Console.WriteLine("Employee new name: {0}", employeeUpdated.FirstName);

                      //delete
                      database.Delete(employeeUpdated);
                      Console.WriteLine("Employee is deleted!");
                      var employeeFound = database.RetrieveObject<Employee>(e=>e.Id==employee.Id);
                      if (employeeFound == null)
                      {
                          Console.WriteLine("Employee is not found!");
                      }

                      //validate
                      employee.LoginId = string.Empty;
                      var brokenRules = employee.ValidateRules();
                      Console.WriteLine(brokenRules[0].ErrorMessage);
                     
                      Console.ReadKey();

                  });

        }
Пример #2
0
        public void Test_Initialization()
        {

            var dbConfig = new DbConfig()
            {
                ConnectionString =  @"Server=meng;Database=EasylinkWalkThrough;User Id=demo;Password=password;",
                DatabaseType = DatabaseType.SqlServer,
                SchemaName = "dbo"

            };

            DatabaseFactory.Initialize(dbConfig);
 
            database = DatabaseFactory.Create();
        }
Пример #3
0
        public void Test_Initialization()
        {

            var dbConfig = new DbConfig()
            {
                ConnectionString = @"Server=meng;Database=easylink;User Id=sa; Password=1197344;",
                DatabaseType = DatabaseType.SqlServer,
                SchemaName = "dbo",
                AuditRecordType = typeof(AuditRecord)
            };

            DatabaseFactory.Initialize(dbConfig);

            database = DatabaseFactory.Create();
 
        }
Пример #4
0
        internal static void Initialize(DbConfig dbConfig)
        {
            _databaseSetup = new DatabaseSetup
                {
                    ConnectionString = dbConfig.ConnectionString,
                    DatabaseType = dbConfig.DatabaseType,
                    SchemaName = dbConfig.SchemaName,
                    AuditRecordType = dbConfig.AuditRecordType
                };

            if (dbConfig.AuditRecordType != null && _isTaskComplete_CheckIfAuditTableExists == false)
             {
                 CheckIfAuditTableExists(dbConfig.AuditRecordType, dbConfig.DatabaseType);

                 _isTaskComplete_CheckIfAuditTableExists = true; 
             }
        }
Пример #5
0
        public void Test_Initialization()
        {


            var dbConfig = new DbConfig()
            {
                ConnectionString = @"Server=meng;Database=easylink;User Id=sa; Password=1197344;",
                DatabaseType = DatabaseType.SqlServer,
                SchemaName = "dbo",
                AuditRecordType = typeof(AuditRecord)
            };

            DatabaseFactory.Initialize(dbConfig);

            database = DatabaseFactory.Create();

            Mapping.SetNextId<BusinessTax>(NextIdOption.AutoIncrement);
            Mapping.SetNextId<PropertyTax>(NextIdOption.AutoIncrement);

        }
Пример #6
0
        public static  void Initialize(DbConfig dbConfig)
        {
            DatabaseSetup.Initialize(dbConfig);

        }