コード例 #1
0
        public void TestAsyncTableElementAtAsync()
        {
            var conn = OrmAsyncTestSession.GetConnection();

            conn.CreateTableAsync <Customer>().Wait();
            conn.ExecuteAsync("delete from customer").Wait();

            // create...
            for (int index = 0; index < 10; index++)
            {
                Customer customer  = this.CreateCustomer();
                customer.FirstName = index.ToString();
                conn.InsertAsync(customer).Wait();
            }

            // query...
            TableQuery <Customer> query = conn.Table <Customer>().OrderBy(v => v.FirstName);
            Task <Customer>       task  = query.ElementAtAsync(7);

            task.Wait();
            Customer loaded = task.Result;

            // check...
            Assert.AreEqual("7", loaded.FirstName);
        }