Exemple #1
0
        public static async Task ASYNC_InsertInTransaction_Commit_TypedRow(ICrudDataStore store)
        {
            var transaction = store.BeginTransactionAsync().Result;

            var tasks = new List <Task>();

            for (var i = 0; i < 25; i++)
            {
                await transaction.InsertAsync(new Patient
                {
                    SSN        = "999-88-9012",
                    First_Name = "Jack",
                    Last_Name  = "Kozloff" + i,
                    DOB        = new DateTime(1980, 1, 12)
                });
            }

            Task.WaitAll(tasks.ToArray());


            var got = await store.LoadAsync(new Query("CRUD.Queries.Patient.List", typeof(Patient)) { new Query.Param("LN", "%loff%") });

            Aver.AreEqual(0, got[0].Count);

            transaction.Commit();

            got = await store.LoadAsync(new Query("CRUD.Queries.Patient.List", typeof(Patient)) { new Query.Param("LN", "%loff%") });

            Aver.AreEqual(25, got[0].Count);
        }
Exemple #2
0
        public static void ASYNC_QueryInsertQuery(ICrudDataStore store)
        {
            var query = new Query("CRUD.Queries.Patient.List")
            {
                new Query.Param("LN", "%loff")
            };
            var task = store.LoadAsync(query);

            Aver.AreEqual(1, task.Result.Count);
            var rowset = task.Result[0];

            Aver.AreEqual(0, rowset.Count);

            var row = new DynamicDoc(rowset.Schema);

            row["ssn"]        = "999-88-9012";
            row["First_Name"] = "Jack";
            row["Last_Name"]  = "Kozloff";
            row["DOB"]        = new DateTime(1980, 1, 12);

            Aver.IsNull(row.Validate());

            store.InsertAsync(row).Wait();


            task = store.LoadAsync(query);

            Aver.AreEqual(1, task.Result.Count);
            rowset = task.Result[0];

            Aver.AreEqual(1, rowset.Count);
            Aver.AreObjectsEqual("Jack", rowset[0]["First_Name"]);
        }
Exemple #3
0
        public static void ASYNC_InsertManyUsingLogChanges_TypedRow(ICrudDataStore store)
        {
            var rowset = new Rowset(Schema.GetForTypedDoc(typeof(Patient)));

            rowset.LogChanges = true;

            for (var i = 0; i < 1000; i++)
            {
                rowset.Insert(new Patient
                {
                    SSN        = "999-88-9012",
                    First_Name = "Jack",
                    Last_Name  = "Kozloff" + i,
                    DOB        = new DateTime(1980, 1, 12)
                });
            }

            for (var i = 0; i < 327; i++)
            {
                rowset.Insert(new Patient
                {
                    SSN        = "999-88-9012",
                    First_Name = "Jack",
                    Last_Name  = "Abramovich" + i,
                    DOB        = new DateTime(2001, 1, 12)
                });
            }

            store.SaveAsync(rowset).Wait();

            var task = store.LoadAsync(new Query("CRUD.Queries.Patient.List", typeof(Patient))
            {
                new Query.Param("LN", "%loff%")
            });

            Aver.AreEqual(1000, task.Result[0].Count);

            task = store.LoadAsync(new Query("CRUD.Queries.Patient.List", typeof(Patient))
            {
                new Query.Param("LN", "%ovich%")
            });

            Aver.AreEqual(327, task.Result[0].Count);
        }