コード例 #1
0
        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]);
        }
        public Net40DefaultDbProviderFactoryService(
            ProviderRowFinder finder)
        {
            DebugCheck.NotNull(finder);

            _finder = finder;
        }
コード例 #3
0
        public static string GetProviderInvariantName(this DbProviderFactory factory)
        {
            DebugCheck.NotNull(factory);

            const int invariantNameIndex = 2;

            var dataRows = DbProviderFactories.GetFactoryClasses().Rows.OfType <DataRow>();

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

            if (row == null)
            {
                if (factory.GetType() == typeof(SqlClientFactory))
                {
                    return("System.Data.SqlClient");
                }

                throw new NotSupportedException(Strings.ProviderNameNotFound(factory));
            }

            return((string)row[invariantNameIndex]);
        }
コード例 #4
0
        public static string GetProviderInvariantName(this DbProviderFactory factory)
        {
            IEnumerable <DataRow> dataRows = DbProviderFactories.GetFactoryClasses().Rows.OfType <DataRow>();
            DataRow row = new ProviderRowFinder().FindRow(factory.GetType(), (Func <DataRow, bool>)(r => DbProviderFactories.GetFactory(r).GetType() == factory.GetType()), dataRows);

            if (row == null)
            {
                throw new NotSupportedException(Strings.ProviderNameNotFound((object)factory));
            }
            return((string)row[2]);
        }
コード例 #5
0
        public static string GetProviderInvariantName(this DbProviderFactory factory)
        {
            DebugCheck.NotNull(factory);

            const int invariantNameIndex = 2;

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

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

            return((string)row[invariantNameIndex]);
        }
コード例 #6
0
        public static string GetProviderInvariantName(this DbProviderFactory factory)
        {
            DebugCheck.NotNull(factory);

            const int invariantNameIndex = 2;

            var dataRows = DbProviderFactories.GetFactoryClasses().Rows.OfType<DataRow>();

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

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

            return (string)row[invariantNameIndex];
        }
コード例 #7
0
        public DefaultDbProviderFactoryService(ProviderRowFinder finder = null)
        {
#if NET40
            _finder = finder ?? new ProviderRowFinder();
#endif
        }