Esempio n. 1
0
            public override IEnumerable <T> ExecuteDeferred <T>(QueryCommand query, Func <FieldReader, T> fnProjector, MappingEntity entity, object[] paramValues)
            {
                IEnumerable <T> enumerable;

                this.LogCommand(query, paramValues);
                this.StartUsingConnection();
                try
                {
                    List <T>  list    = new List <T>();
                    DbCommand command = this.GetCommand(query, paramValues);
                    using (DbDataReader reader = this.ExecuteReader(command))
                    {
                        DbEntityProvider.DbFieldReader arg = new DbEntityProvider.DbFieldReader(this, reader);
                        while (reader.Read())
                        {
                            list.Add(fnProjector(arg));
                        }
                    }
                    enumerable = list;
                }
                finally
                {
                    this.StopUsingConnection();
                }
                return(enumerable);
            }
Esempio n. 2
0
            private IEnumerable <T> ExecuteBatch <T>(QueryCommand query, IEnumerable <object[]> paramSets, Func <FieldReader, T> fnProjector, MappingEntity entity)
            {
                this.LogCommand(query, null);
                DbCommand command = this.GetCommand(query, null);

                command.Prepare();
                List <T> list = new List <T>();

                foreach (object[] objArray in paramSets)
                {
                    this.LogParameters(query, objArray);
                    this.LogMessage("");
                    this.SetParameterValues(query, command, objArray);
                    DbDataReader reader = this.ExecuteReader(command);
                    try
                    {
                        DbEntityProvider.DbFieldReader arg = new DbEntityProvider.DbFieldReader(this, reader);
                        while (reader.Read())
                        {
                            list.Add(fnProjector(arg));
                        }
                    }
                    finally
                    {
                        reader.Close();
                    }
                }
                return(list);
            }
Esempio n. 3
0
 protected virtual IEnumerable <T> Project <T>(DbDataReader reader, Func <FieldReader, T> fnProjector, MappingEntity entity, bool closeReader)
 {
     DbEntityProvider.DbFieldReader arg = new DbEntityProvider.DbFieldReader(this, reader);
     while (reader.Read())
     {
         yield return(fnProjector(arg));
     }
 }