static void TestU() { Console.WriteLine(); IDynaRecord dynaRecord = dataMod.GetDynaRecord("Invo"); dynaRecord.FieldDict["Dt_Fst"].Value = "2017.04.01"; dynaRecord.FieldDict["Dt_Lst"].Value = "2017.04.10"; if (dynaRecord == null) { Console.WriteLine(dataMod.lastError); return; } QueryInvo queryInvo = new QueryInvo(dynaRecord); var query = from invo in queryInvo where invo.Val > 0 orderby invo.Dt_Invo select invo; int count = 0; foreach (Invo invo in query) { Console.WriteLine("{0} {1} {2} {3} {4}", count++, invo.Idn, invo.Dt_Invo, invo.Val, invo.Note); } Console.WriteLine("Done U. Count={0}", count); Invo first = query.First(); Console.WriteLine("Исход.: {0} {1} {2} {3}", first.Idn, first.Dt_Invo, first.Val, first.Note); first.Dt_Invo = DateTime.Parse("07.04.2017"); first.Val = -1500; first.Note = "Попытка изменения данных"; queryInvo.Action(first, "upd"); Console.WriteLine("Измен.: {0} {1} {2} {3}", first.Idn, first.Dt_Invo, first.Val, first.Note); Console.WriteLine(dynaRecord.GetInfo("fields")); }
static void TestR(string queryName, int num) { int count = 0; double sum_gt = 0; int idn; DateTime dt; string note; long m_fst = GC.GetTotalMemory(false); Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); IDynaRecord dynaRecord = dataMod.GetDynaRecord(queryName); DynaReader dynaReader = new DynaReader(dynaRecord); //Iterate 11 ms by click foreach (dynamic d in dynaReader) { count++; idn = d.Idn; dt = d.Dt_Invo; sum_gt += d.Val; note = d.Note; } stopWatch.Stop(); TimeSpan ts = stopWatch.Elapsed; long m_lst = GC.GetTotalMemory(false); Console.WriteLine("R {0}: Кол-во={1}, Сумма={2}. Время {3} ms.", num, count, sum_gt, ts.Milliseconds); Console.WriteLine("Выделено памяти {0}", m_lst - m_fst); timeList.Add(ts.Milliseconds); valList.Add(sum_gt); }
static void TestV() { Console.WriteLine(); IDynaRecord dynaRecord = dataMod.GetDynaRecord("Invo"); dynaRecord.FieldDict["Dt_Fst"].Value = "2017.04.01"; dynaRecord.FieldDict["Dt_Lst"].Value = "2017.04.04"; dynaRecord.FieldDict["Note"].Value = @" Апрель! Апрель! На дворе звенит капель. По полям бегут ручьи, На дорогах лужи."; if (dynaRecord == null) { Console.WriteLine(dataMod.lastError); return; } IDataCommand dynaCmd = dynaRecord as IDataCommand; var out_fields = dynaCmd.Action("c16"); Console.WriteLine("Done V. Rows affected={0}.", dynaCmd.Rows_Affected); foreach (var field in out_fields) { Console.WriteLine("{0} : {1}", field.GetName(), field.Value); } }
static void TestJ() { Console.WriteLine(); long m_fst = GC.GetTotalMemory(false); Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); IDynaRecord dynaRecord = dataMod.GetDynaRecord("InvoCut"); /* * using (FileStream rfs = new FileStream("Invoice_Params.json", FileMode.Open)) * { * //считываем параметры запроса из входного json-потока * dynaRecord.ReadPropStream(rfs, "sel"); * } */ using (Stream fs = new FileStream("InvoCut.json", FileMode.Create), bs = new BufferedStream(fs, 16 * 1024)) { dynaRecord.SelectToStream(bs, CommandBehavior.SequentialAccess); } stopWatch.Stop(); TimeSpan ts = stopWatch.Elapsed; long m_lst = GC.GetTotalMemory(false); //вся таблица выгружается в json-файл размером 381Kb за 14 - 27 ms (TextStreamWriter), лучшее 15 ms //вся таблица выгружается в json-файл размером 381Kb за 35 - 40 ms (JsonStreamWriter), //Core EF читает и пишет данные в поток за 78 - 90 ms Console.WriteLine("Done J: Время {0} ms", ts.Milliseconds); Console.WriteLine("Выделено памяти {0} байт", m_lst - m_fst); }
public QueryInvo(IDynaRecord dynaRecord) : base(dynaRecord) { //MapToCurrent("Idn", "Idn"); //MapToCurrent("Dt_Invo", "DtInvo"); //MapToCurrent("Val", "Val"); //MapToCurrent("Note", "Note"); AutoMapProps(CmdBit.Sel); }
public DynaQuery(IDynaRecord dynaRecord) { _dynaRecord = dynaRecord; _dataCmd = dynaRecord as IDataCommand; _current = Activator.CreateInstance <T>(); _type = _current.GetType(); propMaps = new List <PropMap>(16); sel_Maps = new List <PropMap>(16); list = new List <T>(1024); cached = false; }
static void TestS() { IDynaRecord dynaRecord = dataMod.GetDynaRecord("Invoice"); using (FileStream wfs = new FileStream("Stored_Procs.txt", FileMode.Create)) { StreamWriter sw = new StreamWriter(wfs); sw.WriteLine(dynaRecord.GetInfo("create")); sw.WriteLine(dynaRecord.GetInfo("select")); sw.WriteLine(dynaRecord.GetInfo("detail")); sw.WriteLine(dynaRecord.GetInfo("insert")); sw.WriteLine(dynaRecord.GetInfo("update")); sw.Close(); } }
static void TestM(string queryName, int num) { Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); IDynaRecord dynaRecord = dataMod.GetDynaRecord(queryName); using (MemoryStream ms = new MemoryStream(1000000)) dynaRecord.SelectToStream(ms, CommandBehavior.SequentialAccess); stopWatch.Stop(); TimeSpan ts = stopWatch.Elapsed; //long i_len = dynaObject.StreamWriter.Result.Length; //Console.WriteLine("Done M{0}: Время {1} ms, размер {2}", num, ts.Milliseconds, i_len); timeList.Add(ts.Milliseconds); }
static void TestP(string queryName, int num) { int count = 0; double sum_gt = 0; int idn; DateTime dt; string note; long m_fst = GC.GetTotalMemory(false); Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); IDynaRecord dynaRecord = dataMod.GetDynaRecord(queryName); //Iterate if (dynaRecord == null) { return; } dynamic d = dynaRecord.Ordinal(); int IDN = d.Idn, DT_INVO = d.Dt_Invo, VAL = d.Val, NOTE = d.Note; if (IDN == -1 || DT_INVO == -1 || VAL == -1 || NOTE == -1) { return; } //Iterate 10 ms by click foreach (var r in dynaRecord) //foreach (dynamic d in dynaReader) { count++; idn = r.GetInt32(IDN); dt = r.GetDateTime(DT_INVO); sum_gt += r.GetDouble(VAL); note = r.GetString(NOTE); } stopWatch.Stop(); TimeSpan ts = stopWatch.Elapsed; long m_lst = GC.GetTotalMemory(false); Console.WriteLine("P {0}: Кол-во={1}, Сумма={2}. Время {3} ms.", num, count, sum_gt, ts.Milliseconds); Console.WriteLine("Выделено памяти {0}", m_lst - m_fst); timeList.Add(ts.Milliseconds); valList.Add(sum_gt); }
static void TestQ(string queryName, int num) { int count = 0; double sum_gt = 0; int idn; DateTime dt; string note; //long m_fst = GC.GetTotalMemory(false); Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); IDynaRecord dynaRecord = dataMod.GetDynaRecord(queryName); QueryInvo queryInvo = new QueryInvo(dynaRecord); //LINQ to Objects var query = from invo in queryInvo where invo.Val > num orderby invo.Dt_Invo select invo; //Iterate foreach (Invo invo in query) { count++; idn = invo.Idn; dt = invo.Dt_Invo; sum_gt += invo.Val; note = invo.Note; } stopWatch.Stop(); TimeSpan ts = stopWatch.Elapsed; //long m_lst = GC.GetTotalMemory(false); Console.WriteLine("Q {0}: Кол-во={1}, Сумма={2}. Время {3} ms.", num, count, sum_gt, ts.Milliseconds); //Console.WriteLine("Выделено памяти {0}", m_lst - m_fst); timeList.Add(ts.Milliseconds); valList.Add(sum_gt); }
public DynaReader(IDynaRecord dynaRecord) { _dynaRecord = dynaRecord; _dataCmd = dynaRecord as IDataCommand; }
public DynamicRecord(IDynaRecord dynaRecord, IDataRecord dataRecord) { _record = dynaRecord; _reader = dataRecord; }