public async Task FetchAllAsync() { var orders = await ConnectorOrders.FetchAllAsync(); foreach (var order in orders) { Console.WriteLine($"{order.ID} - {order.Created} - {order.CustomerID}"); } Assert.IsTrue(orders.Count > 0); }
public async Task FetchAllBySqlAsync() { string sql = "SELECT TOP(3) * FROM cat_Orders"; var orders = await ConnectorOrders.FetchAllAsync(sql); foreach (var order in orders) { Console.WriteLine($"{order.ID} - {order.Created} - {order.CustomerID}"); } Assert.IsTrue(orders.Count > 0); }
public async Task FetchWhereInEmptyEnumerableAsync() { var request = new DataQuery <Order>(); request.Add(x => x.ID, new int[] { }, ComparisonOperator.In); var orders = await ConnectorOrders.FetchAllAsync(request); foreach (var order in orders) { Console.WriteLine($"{order.ID} - {order.Created} - {order.CustomerID}"); } Assert.AreEqual(0, orders.Count); }
public async Task FetchWhereInIntAsync() { var request = new DataQuery <Order>(); //request.WhereClause.Add(new DatabaseDataValueColumn("Order_Key", System.Data.SqlDbType.Int, new int[] { 1, 2,3 }, ComparisonOperator.In)); request.Add(x => x.ID, new int[] { 1, 2, 3 }, ComparisonOperator.In); var orders = await ConnectorOrders.FetchAllAsync(request); foreach (var order in orders) { Console.WriteLine($"{order.ID} - {order.Created} - {order.CustomerID}"); } Assert.IsTrue(orders.Count == 3); }
public async Task TestCancellation() { var cts = new CancellationTokenSource(); var filter = new DataQuery <Order>(); cts.Cancel(); try { var orders = await ConnectorOrders.FetchAllAsync(filter, cts.Token); Assert.Fail(); } catch (TaskCanceledException) { } }
public async Task FetchPagingAsync() { var request = new DataQuery <Order>(); request.AddPaging(5, 2); var orders = await ConnectorOrders.FetchAllAsync(request); foreach (var order in orders) { Console.WriteLine($"{order.ID} - {order.Created} - {order.CustomerID}"); } Console.WriteLine("Total number of rows: " + orders.TotalNumberOfRows); Console.WriteLine("Total number of pages: " + orders.TotalNumberOfPages); Assert.IsTrue(orders.Count == request.Paging.NumberOfRows); Assert.IsTrue(request.Paging.TotalNumberOfRows.HasValue); Assert.IsTrue(orders.TotalNumberOfPages.HasValue); Assert.IsTrue(orders.TotalNumberOfRows.HasValue); }