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; }
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; }
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); }
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); }
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); }
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); }
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); }
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)); }
public static QueryEnumerator <T> CreateEnumerator <T>(DbCommandFactor commandFactor, Func <DbCommandFactor, bool, Task <IDataReader> > dataReaderGetter) { return(new QueryEnumerator <T>(commandFactor, dataReaderGetter)); }