Esempio n. 1
0
        private static void InitializeRepoDb()
        {
            var provider = MixService.GetEnumConfig <MixDatabaseProvider>(MixConstants.CONST_SETTING_DATABASE_PROVIDER);

            switch (provider)
            {
            case MixDatabaseProvider.MSSQL:
                SqlServerBootstrap.Initialize();
                break;

            case MixDatabaseProvider.MySQL:
                MySqlBootstrap.Initialize();
                break;

            case MixDatabaseProvider.PostgreSQL:
                PostgreSqlBootstrap.Initialize();
                break;

            case MixDatabaseProvider.SQLITE:
                SqLiteBootstrap.Initialize();
                break;

            default:
                SqLiteBootstrap.Initialize();
                break;
            }
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            // SQL Server Connection for RepoDb
            SqlServerBootstrap.Initialize();

            // Instantiate Menu and WelcomeText
            Menu        menu        = new Menu();
            WelcomeText welcomeText = new WelcomeText();

            // Method for displaing Welcome screen (see Helper folder for refference)
            welcomeText.Print();


            /*Navigation to Menu or Exit of the application.
             * If 'Enter' is pressed -> Menu
             * else if 'Escape' || another key pressed -> close app*/
            switch (Console.ReadKey().Key)
            {
            case ConsoleKey.Enter:
                menu.Index();
                break;

            case ConsoleKey.Escape:
            { }
            break;
            }
        }
Esempio n. 3
0
        // This method gets called by the runtime. Use this method to add services to the container.

        public void ConfigureServices(IServiceCollection services)
        {
            SqlServerBootstrap.Initialize();
            PostgreSqlBootstrap.Initialize();
            MySqlBootstrap.Initialize();

            #region dependency injection

            services.AddTransient <IDatabaseConnectionFactory, NorthWindDbConnectionFactory>();
            services.AddTransient <IDatabaseConnectionFactory, AdemBlogDbConnectionFactory>();
            services.AddTransient <IDatabaseConnectionFactory, FinansDbConnectionFactory>();
            services.AddTransient <IDatabaseConnectionFactory, BookStoreDbConnectionFactory>();

            services.AddTransient <ICategoryService, CategoryManager>();
            services.AddTransient <ICategoryDal, CategoryDal>();

            services.AddTransient <ICashboxService, CashboxManager>();
            services.AddTransient <ICashboxDal, CashboxDal>();

            services.AddTransient <ITagService, TagManager>();
            services.AddTransient <ITagDal, TagDal>();

            services.AddTransient <IPostService, PostManager>();
            services.AddTransient <IPostDal, PostDal>();

            services.AddTransient <IBookService, BookManager>();
            services.AddTransient <IBookDal, BookDal>();

            #endregion dependency injection

            services.AddControllersWithViews();
        }
Esempio n. 4
0
        /// <summary>
        /// Initialize the creation of the database.
        /// </summary>
        public static void Initialize()
        {
            // Get the connection string
            var connectionStringForMaster = Environment.GetEnvironmentVariable("REPODB_CONSTR_MASTER", EnvironmentVariableTarget.Process);
            var connectionString          = Environment.GetEnvironmentVariable("REPODB_CONSTR", EnvironmentVariableTarget.Process);

            // Master connection
            ConnectionStringForMaster = (connectionStringForMaster ?? @"Server=(local);Database=master;Integrated Security=False;User Id=michael;Password=Password123;");

            // RepoDb connection
            ConnectionStringForRepoDb = (connectionString ?? @"Server=(local);Database=RepoDb;Integrated Security=False;User Id=michael;Password=Password123;");

            // Set the proper values for type mapper
            TypeMapper.Add(typeof(DateTime), System.Data.DbType.DateTime2, true);

            // Initialize the SqlServer
            SqlServerBootstrap.Initialize();

            // Create the database first
            CreateDatabase();

            // Create the schemas
            CreateSchemas();

            // Create the tables
            CreateTables();

            // Create the stored procedures
            CreateStoredProcedures();
        }
Esempio n. 5
0
        public void Setup()
        {
            BaseSetup();

            SqlServerBootstrap.Initialize();
            TypeMapper.Add(typeof(DateTime), DbType.DateTime2, true);
        }
Esempio n. 6
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();

            SqlServerBootstrap.Initialize();

            var connection = Configuration.GetValue <string>("ConnectionString");

            services.AddSingleton(new WarehouseRepository(connection));

            services.AddSingleton <IWarehouseObjectRepo>(new WarehouseObjectRepo(connection));

            services.AddSingleton <IWarehouseInlineRepo>(new WarehouseInlineRepo(connection));

            services.AddSingleton <IWarehouseProcedureRepo>(new WarehouseProcedureRepo(connection));

            services.AddSingleton <IWarehouseProvider>(c =>
                                                       new WarehouseProvider(connection, c.GetService <ICache>()));

            services.AddSingleton <IWareHouseUpdator>(c =>
                                                      new WareHouseUpdator(connection, c.GetService <ITrace>()));

            services.AddSingleton <IWareHouseDeletor>(new WareHouseDeletor(connection));

            services.AddSingleton <ICache, MemoryCache>();
            services.AddSingleton <ITrace, CustomTrace>();
        }
Esempio n. 7
0
        public void OpenConnection(string connString)
        {
            var conn = _config.GetConnectionString(connString);

            this._dbconn = new SqlConnection(conn);
            this._dbconn.Open();
            SqlServerBootstrap.Initialize();
        }
 private static void RepoDbConfigInit()
 {
     FluentMapper.Entity <Text>()
     .Table("[dbo].[Texts]")
     .Primary(e => e.Id)
     .Identity(e => e.Id)
     .Column(e => e.Value, "[TextValue]");
     SqlServerBootstrap.Initialize();
 }
Esempio n. 9
0
 public UnitOfWork(IUnitOfWorkConfiguration configuration)
 {
     SqlServerBootstrap.Initialize();
     _config = configuration;
     Task.Run(
         async() =>
     {
         await BeginTransactionAsync();
     }).ConfigureAwait(false).GetAwaiter().GetResult();
 }
Esempio n. 10
0
        public void GlobalSetup()
        {
            SqlServerBootstrap.Initialize();

            var indexOfFirstParameter = Sql.IndexOf("@", StringComparison.Ordinal);

            if (Sql.Substring(0, indexOfFirstParameter) != SqlEFInterpolated.ToString().Substring(0, indexOfFirstParameter))
            {
                throw new Exception();
            }
        }
Esempio n. 11
0
        public static void Initialize()
        {
            // Initialize
            SqlServerBootstrap.Initialize();

            // Models
            FluentMapper
            .Entity <DirectoryCompany>()
            .Table("[directory].[Companies]");
            FluentMapper
            .Entity <SurveyCompany>()
            .Table("[survey].[Companies]");
        }
Esempio n. 12
0
        /// <summary>
        /// Initialize the creation of the database.
        /// </summary>
        public static void Initialize()
        {
            // Master connection
            ConnectionStringForMaster = Environment.GetEnvironmentVariable("REPODB_CONSTR_MASTER", EnvironmentVariableTarget.Process) ??
                                        @"Server=(local);Database=master;Integrated Security=SSPI;TrustServerCertificate=True;";

            // RepoDb connection
            ConnectionStringForRepoDb = Environment.GetEnvironmentVariable("REPODB_CONSTR", EnvironmentVariableTarget.Process) ??
                                        @"Server=(local);Database=RepoDb;Integrated Security=SSPI;TrustServerCertificate=True;";

            // Initialize the SqlServer
            SqlServerBootstrap.Initialize();

            // Create the database first
            CreateDatabase();

            // Create the tables
            CreateTables();
        }
Esempio n. 13
0
        /// <summary>
        /// Initialize the creation of the database.
        /// </summary>
        public static void Initialize()
        {
            // Get the connection string
            var connectionStringForMaster = Environment.GetEnvironmentVariable("REPODB_CONSTR_MASTER", EnvironmentVariableTarget.Process);
            var connectionString          = Environment.GetEnvironmentVariable("REPODB_CONSTR", EnvironmentVariableTarget.Process);

            // Master connection
            ConnectionStringForMaster = (connectionStringForMaster ?? @"Server=(local);Database=master;Integrated Security=False;User Id=michael;Password=Password123;");

            // RepoDb connection
            ConnectionStringForRepoDb = (connectionString ?? @"Server=(local);Database=RepoDb;Integrated Security=False;User Id=michael;Password=Password123;");

            // Initialize the SqlServer
            SqlServerBootstrap.Initialize();

            // Create the database first
            CreateDatabase();

            // Create the tables
            CreateTables();
        }
Esempio n. 14
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();
            services.AddHealthChecks();

            SqlServerBootstrap.Initialize();

            services.AddDbContext <DevTrainingContext>(options =>
                                                       options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));

            services.AddScoped <IUnitOfWork, UnitOfWork>();

            services.AddSingleton <IResponseDto>(new ResponseDto(Configuration.GetConnectionString("DevTrainingContext")));

            services.AddSwaggerGen(c => {
                c.SwaggerDoc("v1", new OpenApiInfo {
                    Title = "DevTraining API", Version = "v1"
                });
                c.EnableAnnotations();
            });
            services.AddAutoMapper(typeof(Startup));
        }
Esempio n. 15
0
        public static void Initialize()
        {
            // Master connection
            ConnectionStringForMaster = Environment.GetEnvironmentVariable("REPODB_CONSTR_MASTER", EnvironmentVariableTarget.Process) ??
                                        @"Server=(local);Database=master;Integrated Security=SSPI;TrustServerCertificate=True;";

            // RepoDb connection
            ConnectionString = Environment.GetEnvironmentVariable("REPODB_CONSTR", EnvironmentVariableTarget.Process) ??
                               @"Server=(local);Database=RepoDbTest;Integrated Security=SSPI;TrustServerCertificate=True;";

            // Initialize the SqlServer
            SqlServerBootstrap.Initialize();

            // Set the DateTime type
            TypeMapper.Add(typeof(DateTime), DbType.DateTime2, true);

            // Create databases
            CreateDatabase();

            // Create tables
            CreateTables();
        }
Esempio n. 16
0
        // DISCLAIMER: I am using System.Diagnostics.Stopwatch to measure performance as it is
        // faster and it suits my presentation purposes. For real-life scenarios, I suggest using
        // Benchmark.NET.
        //
        // I am also using the latest preview versions of all frameworks.
        // These may perform differently compared to stable releases.
        //
        // You may find a better ORM performance comparison here:
        // https://github.com/FransBouma/RawDataAccessBencher/

        public static void Main()
        {
            // LINQ to DB
            DataConnection.DefaultSettings = new CatsDataConnection.DataSettings();

            // RepoDB
            SqlServerBootstrap.Initialize();
            ClassMapper.Add <Cat>("[dbo].[Cats]");
            ClassMapper.Add <Owner>("[dbo].[Owners]");

            // DataSeeder.Seed();

            TooManyQueriesBattle.Fight();
            // LazyLoadingTooManyQueriesBattle.Fight();
            // SelectSpecificColumnsBattle.Fight();
            // IncorrectDataLoadingBattle.Fight();
            // InnerQueryBattle.Fight();
            // DeleteBattle.Fight();
            // DataSeeder.DeleteAndSeed();
            // ColdAndWarmQueriesBattle.Fight();
            // CompiledQueriesBattle.Fight();
            // ChangeTrackingBattle.Fight();
        }
Esempio n. 17
0
        public static void Initialize()
        {
            // Check the connection string
            var connectionStringForMaster = Environment.GetEnvironmentVariable("REPODB_CONSTR_MASTER", EnvironmentVariableTarget.Process);
            var connectionString          = Environment.GetEnvironmentVariable("REPODB_CONSTR", EnvironmentVariableTarget.Process);

            // Master connection
            ConnectionStringForMaster = (connectionStringForMaster ?? @"Server=(local);Database=master;Integrated Security=False;User Id=michael;Password=Password123;");

            // RepoDb connection
            ConnectionString = (connectionString ?? @"Server=(local);Database=RepoDbTest;Integrated Security=False;User Id=michael;Password=Password123;");

            // Initialize the SqlServer
            SqlServerBootstrap.Initialize();

            // Set the DateTime type
            TypeMapper.Map(typeof(DateTime), DbType.DateTime2, true);

            // Create databases
            CreateDatabase();

            // Create tables
            CreateTables();
        }
Esempio n. 18
0
 public void GlobalSetup()
 {
     SqlServerBootstrap.Initialize();
 }
Esempio n. 19
0
 public void Setup()
 {
     BaseSetup();
     SqlServerBootstrap.Initialize();
     ClassMapper.Add <Post>("Posts");
 }
 public CryptoCurrencyDb(string connectionString)
 {
     _connectionString = connectionString;
     SqlServerBootstrap.Initialize();
     CryptoCurrencyDbSetup = new CryptoCurrencyDbSetup(connectionString);
 }
Esempio n. 21
0
 public void Initialize()
 {
     SqlServerBootstrap.Initialize();
 }
Esempio n. 22
0
 public void Setup()
 {
     SqlServerBootstrap.Initialize();
     PostgreSqlBootstrap.Initialize();
 }
Esempio n. 23
0
 static void Bootstrap()
 {
     SqlServerBootstrap.Initialize();
     JobStorage.Current = new MemoryStorage();
 }
Esempio n. 24
0
 /// <summary>
 /// Initializes the current bencher instance.
 /// </summary>
 public override void Initialize()
 {
     base.Initialize();
     SqlServerBootstrap.Initialize();
 }
Esempio n. 25
0
 public ServiceRepoDb(IConfiguration config)
 {
     _config = config;
     SqlServerBootstrap.Initialize();
 }
Esempio n. 26
0
 /// <summary>
 /// SqlServerCommandProvider constructor.
 /// </summary>
 public SqlServerCommandProvider()
 {
     SqlServerBootstrap.Initialize();
 }