public static IEnumerable <T> MultiExec <T>(this SqlProc proc, Action <SqlDataReader, SqlField[]> onReadFields = null, Action <Exception> onError = null) where T : class { var cmd = proc.CreateCommand(); var mapper = new DbObject(); SqlDataReader reader = SqlMultiDyn.ExecMultiReader(proc, onError: onError); if (reader == null) { yield break; } IEnumerable <object[]> worker = ExecMulti(proc, reader, mapper, onReadFields, progress: null); var numerator = worker.GetEnumerator(); Guard.Check(numerator.Current == null); while (numerator.MoveNext()) { object[] record = numerator.Current; T obj = (T)Activator.CreateInstance <T>(); yield return(obj); } }
public static DbObject Exec(SqlProc proc, Action <double> progress = null) { var mapper = new DbObject(); mapper.Worker = DbGetHelper.ExecEnumerable(proc, mapper, progress).GetEnumerator(); if (mapper.Worker == null) { return(null); } return(mapper); }
public static DbObject Exec(SqlProc proc, Action <double> progress = null, bool withFirst = true) { var mapper = new DbObject(); mapper.Worker = DbGetHelper.ExecEnumerable(proc, mapper, progress).GetEnumerator(); if (mapper.Worker == null) { return(null); } if (withFirst && mapper.Worker.Current == null) { mapper.Worker.MoveNext(); } return(mapper); }
public MultiResult <T> Prepare(SqlProc proc , Action <SqlCommand> setup = null , Action <SqlField[]> onReadFields = null , bool noMoveFirst = false ) { this.proc = proc; var mapper = new DbObject(); numerator = DbEnumeratorData.GetEnumerator(() => { this.reader = SqlMultiDyn.ExecMultiReader(proc, setup, progress: null); return(reader); }); if (numerator == null) { return(null); } if (reader.IsClosed || reader.Depth != 0) { return(null); } if (noMoveFirst) { return(this); } numerator.MoveNext(); var rec = numerator.Current as object[]; // DbDataRecord; mapHelper = mapper.GetProperties(reader); Fields = reader.GetFields(); // SqlFieldArray FirstRecord = rec; // mapHelper.SetValues(mapHelper.DbRecordArray()); return(this); }