#pragma warning restore 1591 /// <summary> /// gets a db provider factory by type /// </summary> /// <param name="type"></param> /// <returns></returns> public static DbProviderFactory GetDbProviderFactory(DataAccessProviderTypes type) { if (type == DataAccessProviderTypes.SqlServer) { return(SqlClientFactory.Instance); // this library has a ref to SqlClient so this works } if (type == DataAccessProviderTypes.SqLite) { #if NETFULL return(GetDbProviderFactory("System.Data.SQLite.SQLiteFactory", "System.Data.SQLite")); #else return(GetDbProviderFactory("Microsoft.Data.Sqlite.SqliteFactory", "Microsoft.Data.Sqlite")); #endif } if (type == DataAccessProviderTypes.MySql) { return(GetDbProviderFactory("MySql.Data.MySqlClient.MySqlClientFactory", "MySql.Data")); } if (type == DataAccessProviderTypes.PostgreSql) { return(GetDbProviderFactory("Npgsql.NpgsqlFactory", "Npgsql")); } #if NETFULL if (type == DataAccessProviderTypes.OleDb) { return(System.Data.OleDb.OleDbFactory.Instance); } if (type == DataAccessProviderTypes.SqlServerCompact) { return(DbProviderFactories.GetFactory("System.Data.SqlServerCe.4.0")); } #endif throw new NotSupportedException($"Unsupported provider factory {type.ToString()}"); }
public static DbProviderFactory GetDbProviderFactory(DataAccessProviderTypes type) { //if (type == DataAccessProviderTypes.SqlServer) // return SqlClientFactory.Instance; // this library has a ref to SqlClient so this works if (type == DataAccessProviderTypes.SqlServer) { return(GetDbProviderFactory("System.Data.SqlClient.SqlClientFactory", "System.Data")); } if (type == DataAccessProviderTypes.SqLite) { return(GetDbProviderFactory("Microsoft.Data.Sqlite.SqliteFactory", "Microsoft.Data.Sqlite")); } if (type == DataAccessProviderTypes.MySql) { return(GetDbProviderFactory("MySql.Data.MySqlClient.MySqlClientFactory", "MySql.Data")); } if (type == DataAccessProviderTypes.MySqlConnector) { return(GetDbProviderFactory("MySqlConnector.MySqlConnectorFactory", "MySqlConnector")); } if (type == DataAccessProviderTypes.PostgreSql) { return(GetDbProviderFactory("Npgsql.NpgsqlFactory", "Npgsql")); } //#if NETFULL // if (type == DataAccessProviderTypes.OleDb) // return System.Data.OleDb.OleDbFactory.Instance; // if (type == DataAccessProviderTypes.SqlServerCompact) // return DbProviderFactories.GetFactory("System.Data.SqlServerCe.4.0"); //#endif throw new NotSupportedException("Unsupported Provider Factory: " + type.ToString()); }
/// <summary> /// This method loads various providers dynamically similar to the /// way that DbProviderFactories.GetFactory() works except that /// this API is not available on .NET Standard 2.0 /// </summary> /// <param name="type"></param> /// <returns></returns> public static DbProviderFactory GetDbProviderFactory(DataAccessProviderTypes type) { if (type == DataAccessProviderTypes.SqlServer) { return(SqlClientFactory.Instance); // this library has a ref to SqlClient so this works } if (type == DataAccessProviderTypes.SqLite) { // SqLite support in .NET Standard available now return(GetDbProviderFactory("System.Data.SQLite.SQLiteFactory", "System.Data.SQLite")); //#if NETFULL //#else // return GetDbProviderFactory("Microsoft.Data.Sqlite.SqliteFactory", "Microsoft.Data.Sqlite"); //#endif } if (type == DataAccessProviderTypes.MySql) { return(GetDbProviderFactory("MySql.Data.MySqlClient.MySqlClientFactory", "MySql.Data")); } if (type == DataAccessProviderTypes.PostgreSql) { return(GetDbProviderFactory("Npgsql.NpgsqlFactory", "Npgsql")); } #if NETFULL if (type == DataAccessProviderTypes.OleDb) { return(System.Data.OleDb.OleDbFactory.Instance); } if (type == DataAccessProviderTypes.SqlServerCompact) { return(DbProviderFactories.GetFactory("System.Data.SqlServerCe.4.0")); } #endif throw new NotSupportedException(string.Format(Resources.UnsupportedProviderFactory, type.ToString())); }
public static DbProviderFactory GetDbProviderFactory(DataAccessProviderTypes type) { switch (type) { case DataAccessProviderTypes.SqlServer: return(SqlClientFactory.Instance); case DataAccessProviderTypes.SqLite: return(GetDbProviderFactory("Microsoft.Data.Sqlite.SqliteFactory", "Microsoft.Data.Sqlite")); case DataAccessProviderTypes.MySql: return(GetDbProviderFactory("MySql.Data.MySqlClient.MySqlClientFactory", "MySql.Data")); case DataAccessProviderTypes.PostgreSql: return(GetDbProviderFactory("Npgsql.NpgsqlFactory", "Npgsql")); default: throw new NotSupportedException(string.Format(Resources.UnsupportedProviderFactory, type.ToString())); } }
public static DbProviderFactory GetDbProviderFactory(DataAccessProviderTypes type) { if (type == DataAccessProviderTypes.SqlServer) { return(SqlClientFactory.Instance); // this library has a ref to SqlClient so this works } if (type == DataAccessProviderTypes.SqLite) { return(GetDbProviderFactory("Microsoft.Data.Sqlite.SqliteFactory", "Microsoft.Data.Sqlite")); } if (type == DataAccessProviderTypes.MySql) { return(GetDbProviderFactory("MySql.Data.MySqlClient.MySqlClientFactory", "MySql.Data")); } if (type == DataAccessProviderTypes.PostgreSql) { return(GetDbProviderFactory("Npgsql.NpgsqlFactory", "Npgsql")); } if (type == DataAccessProviderTypes.Oracle) { return(GetDbProviderFactory("Oracle.DataAccess.Client.OracleClientFactory", "Oracle.DataAccess")); } throw new NotSupportedException(string.Format("Unsupported Provider Factory specified: {0}", type.ToString())); }
private static DbProviderFactory GetDbProviderFactory(DataAccessProviderTypes type) { if (type == DataAccessProviderTypes.SqlServer) { return(GetDbProviderFactory("System.Data.SqlClient.SqlClientFactory", "System.Data.SqlClient")); } if (type == DataAccessProviderTypes.SqlServerCore) { return(GetDbProviderFactory("Microsoft.Data.SqlClient.SqlClientFactory", "Microsoft.Data.SqlClient")); } if (type == DataAccessProviderTypes.SqLite) { return(GetDbProviderFactory("Microsoft.Data.Sqlite.SqliteFactory", "Microsoft.Data.Sqlite")); } if (type == DataAccessProviderTypes.MySql) { return(GetDbProviderFactory("MySql.Data.MySqlClient.MySqlClientFactory", "MySql.Data")); } if (type == DataAccessProviderTypes.PostgreSql) { return(GetDbProviderFactory("Npgsql.NpgsqlFactory", "Npgsql")); } if (type == DataAccessProviderTypes.Oracle) { return(GetDbProviderFactory("Oracle.DataAccess.Client.OracleClientFactory", "Oracle.DataAccess")); } throw new NotSupportedException(string.Format("Unsupported Provider Factory specified: {0}", type.ToString())); }