コード例 #1
0
ファイル: DataManager.cs プロジェクト: dbarrera/steag
        public static IDataSource CreateDefaultDataSource()
        {
            var connectionStringKey = SteagConfiguration.Default.ConnectionStringKey;

            var connectionString = ConfigurationManager.ConnectionStrings[connectionStringKey];

            if (Equals(connectionString, null))
                throw new Exception(string.Format("Unknown Connection String {0}", connectionStringKey));

            var providerName = connectionString.ProviderName;
            var factory = DbProviderFactories.GetFactory(providerName);

            if (Equals(factory, null))
                throw new Exception(string.Format("Unknown Provider {0}", providerName));

            var dbConnection = factory.CreateConnection();
            dbConnection.ConnectionString = connectionString.ConnectionString;

            var contextMappingSource = DataCachingManager.Current.MappingSource;

            var mappingSource = new Mapping.MappingSource(string.Empty);
            mappingSource.DataContextMappingSource = contextMappingSource;

            if (Equals(mappingSource, null))
                throw new Exception("Xml Mapping Source is not specified");

            var context = new DataContext(dbConnection, contextMappingSource);
            return new DataSource(dbConnection, context, mappingSource);
        }
コード例 #2
0
ファイル: DataSource.cs プロジェクト: dbarrera/steag
 internal DataSource(IDbConnection connection, DataContext dataContext, Mapping.MappingSource mappingSource)
 {
     Connection = connection;
     MappingSource = mappingSource;
     _dataContext = dataContext;
 }