Example #1
0
        public static void Populate_ASYNC_OpenCursor(ICRUDDataStore store)
        {
            const int CNT = 1000;

            for (var i = 0; i < CNT; i++)
            {
                var patient = new TupleData
                {
                    COUNTER = i,
                    DATA    = i.ToString() + "-DATA"
                };
                store.Insert(patient);
            }



            var query  = new Query <TupleData>("CRUD.Tuple.LoadAll");
            var result = store.LoadOneRowset(query);

            Assert.AreEqual(CNT, result.Count);

            Assert.AreEqual(0, result[0]["COUNTER"]);
            Assert.AreEqual(CNT - 1, result[result.Count - 1]["COUNTER"]);

            var task = store.OpenCursorAsync(query)
                       .ContinueWith(antecedent =>
            {
                var cursor = antecedent.Result;;
                Assert.IsFalse(cursor.Disposed);
                var cnt = 0;
                foreach (var row in cursor.AsEnumerableOf <TupleData>())
                {
                    cnt++;
                }

                Assert.AreEqual(CNT, cnt);
                Assert.IsTrue(cursor.Disposed);                      //foreach must have closed the cursor
            });

            task.Wait();
        }
Example #2
0
        public static void Populate_ASYNC_OpenCursor(ICRUDDataStore store)
        {
            const int CNT = 1000;

            for(var i=0; i<CNT; i++)
            {
              var patient = new TupleData
              {
                 COUNTER = i,
                 DATA = i.ToString()+"-DATA"
              };
              store.Insert( patient );
            }

            var query = new Query<TupleData>("CRUD.Tuple.LoadAll");
            var result = store.LoadOneRowset( query );

            Assert.AreEqual(CNT, result.Count);

            Assert.AreEqual(0, result[0]["COUNTER"]);
            Assert.AreEqual(CNT-1, result[result.Count-1]["COUNTER"]);

            var task = store.OpenCursorAsync( query )
                              .ContinueWith( antecedent =>
                                {
                                    var cursor = antecedent.Result;;
                                    Assert.IsFalse( cursor.Disposed );
                                    var cnt = 0;
                                    foreach(var row in cursor.AsEnumerableOf<TupleData>())
                                    cnt++;

                                    Assert.AreEqual(CNT, cnt);
                                    Assert.IsTrue( cursor.Disposed );//foreach must have closed the cursor
                                });
            task.Wait();
        }