コード例 #1
0
 public override IEnumerable <T> ExecuteDeferred <T>(QueryCommand query, Func <FieldReader, T> fnProjector, MappingEntity entity, object[] paramValues)
 {
     this.LogCommand(query, paramValues);
     this.StartUsingConnection();
     try
     {
         DbCommand cmd     = this.GetCommand(query, paramValues);
         var       reader  = this.ExecuteReader(cmd);
         var       freader = new DbFieldReader(this, reader);
         try
         {
             while (reader.Read())
             {
                 yield return(fnProjector(freader));
             }
         }
         finally
         {
             reader.Close();
         }
     }
     finally
     {
         this.StopUsingConnection();
     }
 }
コード例 #2
0
            private IEnumerable <T> ExecuteBatch <T>(QueryCommand query, IEnumerable <object[]> paramSets, Func <FieldReader, T> fnProjector, MappingEntity entity)
            {
                this.LogCommand(query, null);
                DbCommand cmd = this.GetCommand(query, null);

                cmd.Prepare();
                foreach (var paramValues in paramSets)
                {
                    this.LogParameters(query, paramValues);
                    this.LogMessage("");
                    this.SetParameterValues(query, cmd, paramValues);
                    var reader  = this.ExecuteReader(cmd);
                    var freader = new DbFieldReader(this, reader);
                    try
                    {
                        if (reader.HasRows)
                        {
                            reader.Read();
                            yield return(fnProjector(freader));
                        }
                        else
                        {
                            yield return(default(T));
                        }
                    }
                    finally
                    {
                        reader.Close();
                    }
                }
            }
コード例 #3
0
        private E getEntity(DbFieldReader fieldReader)
        {
            var entity = new E();
            var props  = typeof(E).GetProperties();

            foreach (var prop in props)
            {
                int i = fieldReader.GetOrdinal(prop.Name);
                entity.SetMemberValue(props[i].Name, fieldReader.Read(i, props[i].PropertyType));
            }
            return(entity);
        }
コード例 #4
0
        private IEnumerable <E> mapList(IDataReader reader)
        {
            var fieldReader = new DbFieldReader(reader);

            do
            {
                while (reader.Read())
                {
                    yield return(getEntity(fieldReader));
                }
            } while (reader.NextResult());
        }
コード例 #5
0
ファイル: DbEntityProvider.cs プロジェクト: X10sions/X10sions
            protected virtual IEnumerable <T> Project <T>(DbDataReader reader, Func <FieldReader, T> fnProjector, MappingEntity entity, bool closeReader)
            {
                var freader = new DbFieldReader(this, reader);

                try {
                    while (reader.Read())
                    {
                        yield return(fnProjector(freader));
                    }
                } finally {
                    if (closeReader)
                    {
                        ((IDataReader)reader).Close();
                    }
                }
            }
コード例 #6
0
        private E mapScalar(IDataReader reader)
        {
            var fieldReader = new DbFieldReader(reader);

            return(!reader.Read() ? default(E) : fieldReader.ReadValue <E>(0));
        }