Beispiel #1
0
        public DataSource(
			string name, DataProvider provider, string connectionStringName, 
			string dataOperationsPath, 
			string parameterNamePrefix,
			int commandTimeout)
        {
            _name = name;
            _provider = provider;

            ConnectionStringSettings settings = ConfigurationManager.ConnectionStrings[connectionStringName];

            if (settings == null)
                throw new DataAccessException(ResourceStringLoader.GetResourceString(
                    "connection_string_not_found", connectionStringName));

            _connectionStringName = connectionStringName;

            _templateConnection = (IDbConnection)Activator.CreateInstance(
                _provider.ConnectionObjectType);
            _templateCommand = (IDbCommand)Activator.CreateInstance(
                _provider.CommandObjectType);
            if(_provider.DataAdapterObjectType != null)
                _templateDataAdapter = (IDbDataAdapter)Activator.CreateInstance(
                    _provider.DataAdapterObjectType);

            _parameterNamePrefix = provider.ParameterNamePrefix;
            _commandTimeout = commandTimeout;

            _operationFactory = new DataOperationFactory(this, dataOperationsPath);
        }
        public DataOperationFactory(
			DataSource dataSource, string dataOperationsPath)
        {
            _dataSource = dataSource;
            _provider = dataSource.Provider;

            _commands = new Hashtable();
            _adapters = new Hashtable();

            if(!string.IsNullOrEmpty(dataOperationsPath))
            {
                if(!dataOperationsPath.Substring(1,1).Equals(":") && !dataOperationsPath.StartsWith("\\"))
                    _dataOperationsPath = AppDomain.CurrentDomain.BaseDirectory
                        + Path.DirectorySeparatorChar + dataOperationsPath;
                else
                    _dataOperationsPath = dataOperationsPath;

                LoadCache();
            }
        }