private static void PopulateEFTableAttribute(Type type, EntityMapping mapping, object att) { if (EFDataAnnotiationAdapter.Instance == null) { EFDataAnnotiationAdapter.Init(att.GetType().Assembly); } var tableName = EFDataAnnotiationAdapter.Instance.Table.Name(att) as string; var schemaName = EFDataAnnotiationAdapter.Instance.Table.Schema(att) as string; PopulateTableName(mapping, tableName, type.Name); if (schemaName.HasValue()) { mapping.schema = schemaName; } }
static DbConfiguration() { ManualResetEvent mre = new ManualResetEvent(false); ThreadPool.QueueUserWorkItem(s => { var dlinqAsm = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault(p => p.GetName().Name == "System.Data.Linq"); if (dlinqAsm != null) { DLinq.Init(dlinqAsm); } var dataAnnotiationAsm = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault(p => p.GetName().Name == DataAnnotationMappingAdapter.StrAssemblyName); if (dataAnnotiationAsm != null) { DataAnnotationMappingAdapter.Init(dataAnnotiationAsm); } var efDataAnnotiationAsm = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault(p => p.GetName().Name == EFDataAnnotiationAdapter.StrAssemblyName); if (efDataAnnotiationAsm != null) { EFDataAnnotiationAdapter.Init(efDataAnnotiationAsm); } //初始化PrimitiveMapper Converter.IsPrimitiveType(Types.Boolean); //初始化Expressor var len = MethodRepository.Len; var mappings = NLite.Data.Common.MethodMapping.Mappings; mre.Set(); } ); Options = new Dictionary <string, DbConfigurationInfo>(StringComparer.Ordinal); items = new Dictionary <string, DbConfiguration>(StringComparer.Ordinal); Options["System.Data.OleDb"] = new DbConfigurationInfo { Driver = new AccessDriver(), Dialect = new AccessDialect(), FuncRegistry = new NLite.Data.Dialect.Function.Access.AccessFunctionRegistry(), DbExpressionBuilder = new AssessDbExpressionBuilder(), SqlBuilder = (dialect, funcRegistry) => new AccessSqlBuilder { Dialect = dialect, FuncRegistry = funcRegistry }, ScriptGenerator = () => new AccessScriptGenerator(), ScriptExecutor = () => new AccessScriptExecutor(), SchemaLoader = () => new OledbSchemaLoader(), }; Options["MySql.Data.MySqlClient"] = new DbConfigurationInfo { Driver = new MySqlDriver(), Dialect = new MySqlDialect(), FuncRegistry = new NLite.Data.Dialect.Function.MySQL.MySqlFunctionRegistry(), DbExpressionBuilder = new MySqlExpressionBuilder(), SqlBuilder = (dialect, funcRegistry) => new MySqlBuilder { Dialect = dialect, FuncRegistry = funcRegistry }, ScriptGenerator = () => new MySQLScriptGenerator(), ScriptExecutor = () => new MySQLScriptExecutor(), SchemaLoader = () => new MySqlSchemaLoader(), }; Options["Oracle.DataAccess.Client"] = new DbConfigurationInfo { Driver = new OracleODPDriver(), Dialect = new OracleDialect(), FuncRegistry = new NLite.Data.Dialect.Function.Oracle.OracleFunctionRegistry(), DbExpressionBuilder = new OracleExpressionBuilder(), SqlBuilder = (dialect, funcRegistry) => new OracleSqlBuilder { Dialect = dialect, FuncRegistry = funcRegistry }, ScriptGenerator = () => new OracleScriptGenerator(), ScriptExecutor = () => new OracleScriptExecutor(), SchemaLoader = () => new OracleSchemaLoader(), }; Options["System.Data.OracleClient"] = new DbConfigurationInfo { Driver = new OracleClientDriver(), Dialect = new OracleDialect(), FuncRegistry = new NLite.Data.Dialect.Function.Oracle.OracleFunctionRegistry(), DbExpressionBuilder = new OracleExpressionBuilder(), SqlBuilder = (dialect, funcRegistry) => new OracleSqlBuilder { Dialect = dialect, FuncRegistry = funcRegistry }, ScriptGenerator = () => new OracleScriptGenerator(), ScriptExecutor = () => new OracleScriptExecutor(), SchemaLoader = () => new OracleSchemaLoader(), }; Options["System.Data.SqlClient"] = new DbConfigurationInfo { Driver = new SqlServer2005Driver(), Dialect = new MsSql2005Dialect(), FuncRegistry = new NLite.Data.Dialect.Function.MsSql.MsSql2005FunctionRegistry(), DbExpressionBuilder = new MsSql2005ExpressionBuilder(), SqlBuilder = (dialect, funcRegistry) => new SqlServer2005SqlBuilder { Dialect = dialect, FuncRegistry = funcRegistry }, ScriptGenerator = () => new SqlServerScriptGenerator(), ScriptExecutor = () => new SqlServerScriptExecutor(), SchemaLoader = () => new SqlServerSchemaLoader(), }; Options["System.Data.SQLite"] = new DbConfigurationInfo { Driver = new SQLiteDriver(), Dialect = new SQLiteDialect(), FuncRegistry = new NLite.Data.Dialect.Function.SQLite.SQLiteFunctionManager(), DbExpressionBuilder = new SQLiteExpressionBuilder(), SqlBuilder = (dialect, funcRegistry) => new SQLiteSqlBuilder { Dialect = dialect, FuncRegistry = funcRegistry }, ScriptGenerator = () => new SQLiteScriptGenerator(), ScriptExecutor = () => new SQLiteScriptExecutor(), SchemaLoader = () => new SQLiteSchemaLoader(), }; Options["System.Data.SqlServerCe.3.5"] = new DbConfigurationInfo { Driver = new SqlCeDriver(), Dialect = new SqlCe35Dialect(), FuncRegistry = new NLite.Data.Dialect.Function.SqlCe.SqlCeFunctionRegistry(), DbExpressionBuilder = new SqlCe35ExpressionBuilder(), SqlBuilder = (dialect, funcRegistry) => new SqlCeBuilder { Dialect = dialect, FuncRegistry = funcRegistry }, ScriptGenerator = () => new SqlCeScriptGenerator(), ScriptExecutor = () => new SqlCeScriptExecutor(), SchemaLoader = () => new SqlCeSchemaLoader(), }; Options["System.Data.SqlServerCe.4.0"] = new DbConfigurationInfo { Driver = new SqlCeDriver(), Dialect = new SqlCe35Dialect(), FuncRegistry = new NLite.Data.Dialect.Function.SqlCe.SqlCeFunctionRegistry(), DbExpressionBuilder = new SqlCe35ExpressionBuilder(), SqlBuilder = (dialect, funcRegistry) => new SqlCeBuilder { Dialect = dialect, FuncRegistry = funcRegistry }, ScriptGenerator = () => new SqlCeScriptGenerator(), ScriptExecutor = () => new SqlCeScriptExecutor(), SchemaLoader = () => new SqlCeSchemaLoader(), }; providerNames = new HashSet <string>(StringComparer.OrdinalIgnoreCase); foreach (var item in DbProviderFactories.GetFactoryClasses().Rows.Cast <DataRow>().Select(p => p["InvariantName"] as string)) { providerNames.Add(item); } mre.WaitOne(); mre.Close(); }