public static string GetProviderInvariantName(this DbProviderFactory factory)
        {
            DebugCheck.NotNull(factory);

            const int invariantNameIndex = 2;

#if NETSTANDARD
            var dataRows = DbProviderFactoriesCore.GetFactoryClasses().Rows.OfType <DataRow>();

            var row = new ProviderRowFinder().FindRow(
                factory.GetType(),
                r => DbProviderFactoriesCore.GetFactory(r).GetType() == factory.GetType(),
                dataRows);
#else
            var dataRows = DbProviderFactories.GetFactoryClasses().Rows.OfType <DataRow>();

            var row = new ProviderRowFinder().FindRow(
                factory.GetType(),
                r => DbProviderFactories.GetFactory(r).GetType() == factory.GetType(),
                dataRows);
#endif

            if (row == null)
            {
                throw new NotSupportedException(Strings.ProviderNameNotFound(factory));
            }

            return((string)row[invariantNameIndex]);
        }
Exemplo n.º 2
0
        public DbProviderFactory ResolveProviderFactory(DbConnection connection)
        {
            Check.NotNull(connection, "connection");

#if NETSTANDARD
            return(GetProviderFactory(connection, DbProviderFactoriesCore.GetFactoryClasses().Rows.OfType <DataRow>()));
#else
            return(GetProviderFactory(connection, DbProviderFactories.GetFactoryClasses().Rows.OfType <DataRow>()));
#endif
        }