예제 #1
0
 /// <summary>
 /// Converts the <see cref="DbDataReader"/> into an enumerable of <see cref="ExpandoObject"/> object.
 /// </summary>
 /// <param name="reader">The <see cref="DbDataReader"/> to be converted.</param>
 /// <param name="basedOnFields">Check whether to create a delegate based on the data reader fields.</param>
 /// <returns>An array of <see cref="ExpandoObject"/> objects.</returns>
 internal static IEnumerable <dynamic> ToEnumerable(DbDataReader reader, bool basedOnFields = false)
 {
     if (reader != null && reader.HasRows)
     {
         var @delegate = DelegateCache.GetDataReaderToExpandoObjectDelegate(reader, basedOnFields);
         while (reader.Read())
         {
             yield return(@delegate(reader));
         }
     }
 }