예제 #1
0
파일: Program.cs 프로젝트: Kobdik/DynaRepo
        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"));
        }
예제 #2
0
파일: Program.cs 프로젝트: Kobdik/DynaRepo
        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);
        }