Beispiel #1
0
        protected override void OnSetup()
        {
            ICollection <string> settingsKeys = ((IDictionary <string, object>)Settings).Keys;

            if (settingsKeys.Contains("ConnectionString"))
            {
                if (settingsKeys.Contains("ProviderName"))
                {
                    _connectionProvider = ProviderHelper.GetProviderByConnectionString(Settings.ConnectionString,
                                                                                       Settings.ProviderName);
                }
                else
                {
                    _connectionProvider = ProviderHelper.GetProviderByConnectionString(Settings.ConnectionString);
                }
            }
            else if (settingsKeys.Contains("Filename"))
            {
                _connectionProvider = ProviderHelper.GetProviderByFilename(Settings.Filename);
            }
            else if (settingsKeys.Contains("ConnectionName"))
            {
                _connectionProvider = ProviderHelper.GetProviderByConnectionName(Settings.ConnectionName);
            }
            _schema           = DatabaseSchema.Get(_connectionProvider, _providerHelper);
            _relatedFinder    = new Lazy <AdoAdapterRelatedFinder>(CreateRelatedFinder);
            _commandOptimizer = ProviderHelper.GetCustomProvider <CommandOptimizer>(_connectionProvider) ??
                                new CommandOptimizer();
        }
Beispiel #2
0
        protected override void OnSetup()
        {
            var settingsKeys = ((IDictionary <string, object>)Settings).Keys;

            if (settingsKeys.Contains("ConnectionString"))
            {
                _connectionProvider = ProviderHelper.GetProviderByConnectionString(Settings.ConnectionString);
            }
            else if (settingsKeys.Contains("Filename"))
            {
                _connectionProvider = ProviderHelper.GetProviderByFilename(Settings.Filename);
            }
            _schema        = DatabaseSchema.Get(_connectionProvider);
            _relatedFinder = new Lazy <AdoAdapterRelatedFinder>(CreateRelatedFinder);
        }
 public void ShouldFindForeignKeysUsingCreateTableSql()
 {
     var providerHelper = new ProviderHelper();
     var connectionProvider = providerHelper.GetProviderByConnectionString(ConnectionString);
     var schemaProvider = connectionProvider.GetSchemaProvider();
     var databaseSchema = DatabaseSchema.Get(connectionProvider, providerHelper);
     var table = databaseSchema.FindTable("orderitems_fk_test");
     var foreignKeys = schemaProvider.GetForeignKeys(table);
     var items_fk_test = foreignKeys.FirstOrDefault(fk => fk.MasterTable.Name == "items_fk_test");
     Assert.IsNotNull(items_fk_test);
     CollectionAssert.AreEqual(new[] { "ItemsId" }, items_fk_test.Columns.AsEnumerable());
     CollectionAssert.AreEqual(new[] { "ItemId" }, items_fk_test.UniqueColumns.AsEnumerable());
     var orders_fk_test = foreignKeys.FirstOrDefault(fk => fk.MasterTable.Name == "orders_fk_test");
     Assert.IsNotNull(orders_fk_test);
     CollectionAssert.AreEqual(new[] { "OrdersId" }, orders_fk_test.Columns.AsEnumerable());
     CollectionAssert.AreEqual(new[] { "OrderId" }, orders_fk_test.UniqueColumns.AsEnumerable());
 }