public List <T> GetNextResultSet <T>() { if (!InitConnection()) { if (!sqlDataReader.NextResult()) { throw new InvalidOperationException("There is no result set left"); } } var fillVisitor = new FillVisitor( reader: sqlDataReader, db: db, objectFillerFactory: new ObjectFillerFactory()); var resultSet = new List <T>(); var configuration = GlobalDbConfiguration.GetConfigurationOrEmpty(typeof(T)); var entityFilter = configuration.EntityFilter; var queryLogger = GlobalDbConfiguration.QueryLogger; while (sqlDataReader.Read()) { var entity = fillVisitor.Fill <T>(); queryLogger.IncrementLoadedElementCount(increment: 1); if (entityFilter.DoReturnEntity(db.Settings, entity)) { EmitValueLoaded(entity); resultSet.Add(entity); } } return(resultSet); }
public static object Fill(Type type, object entity, FillVisitor fillVisitor) { var helper = GetHelperOrNull(type); if (helper != null) { return(helper.Fill(entity, fillVisitor)); } entity = fillVisitor.Fill(type); return(entity); }
public static T Fill <T>(T entity, FillVisitor fillVisitor) { var helper = GetHelperOrNull <T>(); if (helper != null) { return(helper.Fill(entity, fillVisitor)); } entity = fillVisitor.Fill <T>(); var dbEntity = entity as IDbEntityInternal; if (dbEntity != null) { dbEntity.ModifyInternalState(new InsertSetVisitor(doReset: true)); dbEntity.SetDb(fillVisitor.DbInternal); } return(entity); }