Beispiel #1
0
        public static IQueryRunner CreateHelper(DataAccessSectionSettings settings, IQueryMappers mapper)
        {
            try
            {
                var providerType = settings.Type;

                var daType = Type.GetType(providerType);
                if (daType == null)
                {
                    throw new NullReferenceException("Null Reference in Provider type configuration Session.");
                }

                var provider = Activator.CreateInstance(daType, settings.ConnectionString, mapper);
                if (provider is QueryRunner)
                {
                    return(provider as IQueryRunner);
                }

                throw new Exception("The provider specified does not extends the QueryRunner abstract class.");
            }
            catch (Exception e)
            {
                throw new Exception("If the section is not defined on the configuration file this method can't be used to create an QueryRunner instance.", e);
            }
        }
Beispiel #2
0
        public QueryMapperResult(IQueryMappers mapper, dynamic source)
        {
            if (mapper == null)
            {
                throw new ArgumentNullException("mapper", "Mapper can't be null in QueryMapperResult");
            }

            this.mapper = mapper;
            this.source = source;
        }
        internal QueryMapperResult(IQueryMappers mapper, dynamic source, bool keepCache = true)
        {
            if (mapper == null)
            {
                throw new ArgumentNullException(nameof(mapper), "Mapper can't be null in QueryMapperResult");
            }

            this.mapper    = mapper;
            this.source    = source;
            this.keepCache = keepCache;
        }
        public static IQueryRunner CreateHelper(string providerAlias, IQueryMappers mapper)
        {
            try
            {
                var dict = ConfigurationManager.GetSection("daProviders") as IDictionary;
                if (dict == null)
                {
                    throw new NullReferenceException("Null Reference in DataAccess Provider configuration Session.");
                }

                var providerConfig = dict[providerAlias] as ProviderAlias;
                if (providerConfig == null)
                {
                    throw new NullReferenceException("Null Reference in Provider Alias configuration Session.");
                }

                var providerType = providerConfig.TypeName;
                ConnectionString = providerConfig.ConnectionString;

                var daType = Type.GetType(providerType);
                if (daType == null)
                {
                    throw new NullReferenceException("Null Reference in Provider type configuration Session.");
                }

                var provider = Activator.CreateInstance(daType, mapper);
                if (provider is QueryRunner)
                {
                    return(provider as IQueryRunner);
                }

                throw new Exception("The provider specified does not extends the AdoHelper abstract class.");
            }
            catch (Exception e)
            {
                throw new Exception("If the section is not defined on the configuration file this method can't be used to create an AdoHelper instance.", e);
            }
        }
Beispiel #5
0
        public static IQueryRunner CreateHelper(string providerAlias, IQueryMappers mapper)
        {
            try
            {
                var dict = ConfigurationManager.GetSection("DataQueryProviders") as IDictionary;
                if (dict == null)
                {
                    throw new NullReferenceException("Null Reference in DataAccess Provider configuration Session.");
                }

                var providerConfig = dict[providerAlias] as ProviderAlias;
                if (providerConfig == null)
                {
                    throw new NullReferenceException("Null Reference in Provider Alias configuration Session.");
                }

                return(CreateHelper(new DataAccessSectionSettings(providerConfig.TypeName, providerConfig.ConnectionString), mapper));
            }
            catch (Exception e)
            {
                throw new Exception("If the section is not defined on the configuration file this method can't be used to create an AdoHelper instance.", e);
            }
        }
 protected QueryRunner(string connectionString, IQueryMappers mapper = null)
 {
     this.mapper           = mapper;
     this.ConnectionString = connectionString;
 }
Beispiel #7
0
 public MsSql(string connectionString, IQueryMappers mapper = null) : base(connectionString, mapper)
 {
 }
Beispiel #8
0
 public PgSql(IQueryMappers mapper) : base(mapper)
 {
 }
 public MockQueryRunner(string connectionString, IQueryMappers mapper = null) : base(connectionString, mapper)
 {
 }
 protected QueryRunner(IQueryMappers mapper)
 {
     this.mapper = mapper;
 }
Beispiel #11
0
 public MockQueryRunner(IQueryMappers mapper) : base(mapper)
 {
 }