Esempio n. 1
0
        public IEnumerator <T> GetEnumerator()
        {
            DbCommandFactor commandFactor = this.GenerateCommandFactor();
            var             enumerator    = QueryEnumeratorCreator.CreateEnumerator <T>(this._query.DbContext.AdoSession, commandFactor);

            return(enumerator);
        }
            public QueryEnumerator(InternalAdoSession adoSession, DbCommandFactor commandFactor)
            {
                this._adoSession      = adoSession;
                this._commandFactor   = commandFactor;
                this._objectActivator = commandFactor.ObjectActivator;

                this._reader = null;

                this._current     = default(T);
                this._hasFinished = false;
                this._disposed    = false;
            }
Esempio n. 3
0
        public QueryEnumerator(DbCommandFactor commandFactor, Func <DbCommandFactor, bool, Task <IDataReader> > dataReaderGetter)
        {
            this._commandFactor    = commandFactor;
            this._dataReaderGetter = dataReaderGetter;
            this._objectActivator  = commandFactor.ObjectActivator;

            this._reader = null;

            this._current     = default(T);
            this._hasFinished = false;
            this._disposed    = false;
        }
Esempio n. 4
0
        public IEnumerator <T> GetEnumerator()
        {
            DbCommandFactor     commandFactor = this.GenerateCommandFactor();
            QueryEnumerator <T> enumerator    = new QueryEnumerator <T>(async(@async) =>
            {
                IDataReader dataReader = await this._query.DbContext.Session.ExecuteReader(commandFactor.CommandText, CommandType.Text, commandFactor.Parameters, @async);

                return(DataReaderReady(dataReader, commandFactor.ObjectActivator));
            }, commandFactor.ObjectActivator);

            return(enumerator);
        }
Esempio n. 5
0
        DbCommandFactor GenerateCommandFactor()
        {
            IQueryState qs   = QueryExpressionVisitor.VisitQueryExpression(this._query.QueryExpression);
            MappingData data = qs.GenerateMappingData();

            IObjectActivator objectActivator;

            objectActivator = data.ObjectActivatorCreator.CreateObjectActivator();

            IDbExpressionTranslator translator = this._query.DbContext._dbContextServiceProvider.CreateDbExpressionTranslator();
            List <DbParam>          parameters;
            string cmdText = translator.Translate(data.SqlQuery, out parameters);

            DbCommandFactor commandFactor = new DbCommandFactor(objectActivator, cmdText, parameters.ToArray());

            return(commandFactor);
        }
Esempio n. 6
0
        public IEnumerator <T> GetEnumerator()
        {
            DbCommandFactor commandFactor = this.GenerateCommandFactor();
            var             enumerator    = QueryEnumeratorCreator.CreateEnumerator <T>(commandFactor, cmdFactor =>
            {
                IDataReader dataReader = this._query.DbContext.AdoSession.ExecuteReader(cmdFactor.CommandText, cmdFactor.Parameters, CommandType.Text);

                if (cmdFactor.ObjectActivator is RootEntityActivator)
                {
                    dataReader = new QueryDataReader(dataReader);
                }

                cmdFactor.ObjectActivator.Prepare(dataReader);

                return(dataReader);
            });

            return(enumerator);
        }
Esempio n. 7
0
        DbCommandFactor GenerateCommandFactor()
        {
            IQueryState qs   = QueryExpressionResolver.Resolve(this._query.QueryExpression, new ScopeParameterDictionary(), new StringSet());
            MappingData data = qs.GenerateMappingData();

            IObjectActivator objectActivator;

            if (this._query._trackEntity)
            {
                objectActivator = data.ObjectActivatorCreator.CreateObjectActivator(this._query.DbContext);
            }
            else
            {
                objectActivator = data.ObjectActivatorCreator.CreateObjectActivator();
            }

            IDbExpressionTranslator translator    = this._query.DbContext.DatabaseProvider.CreateDbExpressionTranslator();
            DbCommandInfo           dbCommandInfo = translator.Translate(data.SqlQuery);

            DbCommandFactor commandFactor = new DbCommandFactor(objectActivator, dbCommandInfo.CommandText, dbCommandInfo.GetParameters());

            return(commandFactor);
        }
Esempio n. 8
0
        DbCommandFactor GenerateCommandFactor()
        {
            IQueryState qs   = QueryExpressionVisitor.VisitQueryExpression(this._query.QueryExpression, new ScopeParameterDictionary(), new KeyDictionary <string>());
            MappingData data = qs.GenerateMappingData();

            IObjectActivator objectActivator;

            if (this._query._trackEntity)
            {
                objectActivator = data.ObjectActivatorCreator.CreateObjectActivator(this._query.DbContext);
            }
            else
            {
                objectActivator = data.ObjectActivatorCreator.CreateObjectActivator();
            }

            IDbExpressionTranslator translator = this._query.DbContext.DatabaseProvider.CreateDbExpressionTranslator();
            List <DbParam>          parameters;
            string cmdText = translator.Translate(data.SqlQuery, out parameters);

            DbCommandFactor commandFactor = new DbCommandFactor(objectActivator, cmdText, parameters.ToArray());

            return(commandFactor);
        }
Esempio n. 9
0
        public override string ToString()
        {
            DbCommandFactor commandFactor = this.GenerateCommandFactor();

            return(InternalAdoSession.AppendDbCommandInfo(commandFactor.CommandText, commandFactor.Parameters));
        }
 public static IEnumerator <T> CreateEnumerator <T>(InternalAdoSession adoSession, DbCommandFactor commandFactor)
 {
     return(new QueryEnumerator <T>(adoSession, commandFactor));
 }
Esempio n. 11
0
 public static QueryEnumerator <T> CreateEnumerator <T>(DbCommandFactor commandFactor, Func <DbCommandFactor, bool, Task <IDataReader> > dataReaderGetter)
 {
     return(new QueryEnumerator <T>(commandFactor, dataReaderGetter));
 }