public T ReadSingle(DbDataReader reader, ObjectsChangeTracker changeTracker)
        {
            T result = reader.Read() ? MapUsingState(reader, reader) : default(T);

            if (changeTracker != null)
            {
                changeTracker.RegisterObject(result);
            }
            return(result);
        }
 public IEnumerable <T> ReadCollection(DbDataReader reader, ObjectsChangeTracker changeTracker)
 {
     while (reader.Read())
     {
         T result = MapUsingState(reader, reader);
         if (changeTracker != null)
         {
             changeTracker.RegisterObject(result);
         }
         yield return(result);
     }
     reader.Close();
 }
Exemple #3
0
 public static IEnumerable <T> ToObjects <T>(this DbDataReader reader, string readerName, string[] excludeFields, ObjectsChangeTracker changeTracker)
 {
     if (string.IsNullOrEmpty(readerName))
     {
         var mappingKeyBuilder = new StringBuilder();
         for (int i = 0; i < reader.FieldCount; ++i)
         {
             mappingKeyBuilder.Append(reader.GetName(i));
             mappingKeyBuilder.Append(' ');
         }
         readerName = mappingKeyBuilder.ToString();
     }
     return(new DataReaderToObjectMapper <T>(readerName, null, excludeFields).ReadCollection(reader, changeTracker));
 }
Exemple #4
0
        public static T ToObject <T>(this DbDataReader reader, string readerName, string[] excludeFields, ObjectsChangeTracker changeTracker)
        {
            T result = new DataReaderToObjectMapper <T>(readerName, null, excludeFields).MapUsingState(reader, reader);

            if (changeTracker != null)
            {
                changeTracker.RegisterObject(result);
            }
            return(result);
        }