/// <summary> /// Returns a list of dynamic objects whose properties and types match up with that database name. /// </summary> /// <param name="reader">The reader.</param> /// <param name="whereColumn">The where column name.</param> /// <param name="whereColumnEquals">What the were column should equal.</param> /// <returns></returns> static public IEnumerable <dynamic> DynamicAllRecords(this DBFReader reader, string whereColumn = null, dynamic whereColumnEquals = null) { var tProperties = reader.GetSelectFields().Select(it => it.Name).ToArray(); int?tWhereColumn = null; if (!String.IsNullOrEmpty(whereColumn)) { tWhereColumn = Array.FindIndex(tProperties, it => it.Equals(whereColumn, StringComparison.InvariantCultureIgnoreCase)); } var tReturn = new List <object>(); object[] t = reader.NextRecord(); while (t != null) { if (tWhereColumn.HasValue) { dynamic tO = t[tWhereColumn.Value]; if (!tO.Equals(whereColumnEquals)) { t = reader.NextRecord(); continue; } } var tIntercepter = new Enumerable.DBFIntercepter(t, tProperties); tReturn.Add(tIntercepter); t = reader.NextRecord(); } return(tReturn); }
/// <summary> /// Returns a list of dynamic objects whose properties and types match up with that database name. /// </summary> /// <param name="reader">The reader.</param> /// <param name="whereColumn">The where column name.</param> /// <param name="whereColumnEquals">What the were column should equal.</param> /// <returns></returns> public static IEnumerable <dynamic> DynamicAllRecords(this DBFReader reader, string whereColumn = null, dynamic whereColumnEquals = null) { var props = reader.GetSelectFields().Select(it => it.Name).ToArray(); int?whereColumnIndex = null; if (!String.IsNullOrEmpty(whereColumn)) { whereColumnIndex = Array.FindIndex(props, it => it.Equals(whereColumn, StringComparison.InvariantCultureIgnoreCase)); } var tReturn = new List <object>(); var t = reader.NextRecord(); while (t != null) { if (whereColumnIndex is int i) { dynamic tO = t[i]; if (!tO.Equals(whereColumnEquals)) { t = reader.NextRecord(); continue; } } var interceptor = new Enumerable.DBFInterceptor(t, props); tReturn.Add(interceptor); t = reader.NextRecord(); } return(tReturn); }