Ejemplo n.º 1
0
        public IQueryLite <OrderDetail> SearchQuery(OrderDetailSearchCriteria criteria)
        {
            var query = this.Query(Projection.Extended);

            if (criteria.City != null)
            {
                query.And(nameof(OrderDetail.City), OperatorLite.Equals, criteria.City);
            }
            if (criteria.Country != null)
            {
                query.And(nameof(OrderDetail.Country), OperatorLite.Equals, criteria.Country);
            }
            if (criteria.CustomerId != null)
            {
                query.And(nameof(OrderDetail.CustomerId), OperatorLite.Equals, criteria.CustomerId);
            }
            if (criteria.CustomerName != null)
            {
                query.And(nameof(OrderDetail.CustomerName), OperatorLite.StartsWith, criteria.CustomerName);
            }
            if (criteria.FromDate.HasValue)
            {
                query.And(nameof(OrderDetail.OrderDate), OperatorLite.GreaterOrEquals, criteria.FromDate);
            }
            if (criteria.MaxPrice.HasValue)
            {
                query.And(nameof(OrderDetail.UnitPrice), OperatorLite.LessOrEquals, criteria.MaxPrice);
            }
            if (criteria.MinPrice.HasValue)
            {
                query.And(nameof(OrderDetail.UnitPrice), OperatorLite.GreaterOrEquals, criteria.MinPrice);
            }
            if (criteria.OrderId.HasValue)
            {
                query.And(nameof(OrderDetail.OrderId), OperatorLite.Equals, criteria.OrderId);
            }
            if (criteria.ProductId.HasValue)
            {
                query.And(nameof(OrderDetail.ProductId), OperatorLite.Equals, criteria.ProductId);
            }
            if (criteria.ProductName != null)
            {
                query.And(nameof(OrderDetail.ProductName), OperatorLite.StartsWith, criteria.ProductName);
            }
            if (criteria.Region != null)
            {
                query.And(nameof(OrderDetail.Region), OperatorLite.Equals, criteria.Region);
            }
            if (criteria.ToDate.HasValue)
            {
                query.And(nameof(OrderDetail.OrderDate), OperatorLite.LessOrEquals, criteria.ToDate);
            }
            return(query);
        }
Ejemplo n.º 2
0
 public IQueryLite<OrderDetail> SearchQuery(OrderDetailSearchCriteria criteria)
 {
     var query = this.Query(Projection.Extended);
     if (criteria.City != null) query.And(OrderDetailFields.City, OperatorLite.Equals, criteria.City);
     if (criteria.Country != null) query.And(OrderDetailFields.Country, OperatorLite.Equals, criteria.Country);
     if (criteria.CustomerId != null) query.And(OrderDetailFields.CustomerId, OperatorLite.Equals, criteria.CustomerId);
     if (criteria.CustomerName != null) query.And(OrderDetailFields.CustomerName, OperatorLite.StartsWith, criteria.CustomerName);
     if (criteria.FromDate.HasValue) query.And(OrderDetailFields.OrderDate, OperatorLite.GreaterOrEquals, criteria.FromDate);
     if (criteria.MaxPrice.HasValue) query.And(OrderDetailFields.UnitPrice, OperatorLite.LessOrEquals, criteria.MaxPrice);
     if (criteria.MinPrice.HasValue) query.And(OrderDetailFields.UnitPrice, OperatorLite.GreaterOrEquals, criteria.MinPrice);
     if (criteria.OrderId.HasValue) query.And(OrderDetailFields.OrderId, OperatorLite.Equals, criteria.OrderId);
     if (criteria.ProductId.HasValue) query.And(OrderDetailFields.ProductId, OperatorLite.Equals, criteria.ProductId);
     if (criteria.ProductName != null) query.And(OrderDetailFields.ProductName, OperatorLite.StartsWith, criteria.ProductName);
     if (criteria.Region != null) query.And(OrderDetailFields.Region, OperatorLite.Equals, criteria.Region);
     if (criteria.ToDate.HasValue) query.And(OrderDetailFields.OrderDate, OperatorLite.LessOrEquals, criteria.ToDate);
     return query;
 }
Ejemplo n.º 3
0
        //private static void EmployeeSubTree_RefCursor()
        //{
        //    using (var ds = new NorthwindDataService())
        //    {
        //        object cSubTree;
        //        ds.EmployeeRepository.EmployeeSubtree(2, out cSubTree);
        //        IDataReader reader = ((dynamic)cSubTree).GetDataReader();
        //        foreach(var employee in reader.ToList<Employee>())
        //        {
        //            Console.WriteLine("{0}, {1}", employee.FirstName, employee.LastName);
        //        }
        //    }
        //}
        private static void SearchOrderDetails()
        {
            Console.WriteLine("\nSearchOrderDetails\n");
            var criteria = new OrderDetailSearchCriteria
            {
                ProductName = "C",
                CustomerId = "AROUT"
            };

            var orderDetails = ds.OrderDetailRepository.SearchQuery(criteria)
                .Fields(OrderDetailFields.OrderId, OrderDetailFields.OrderDate, OrderDetailFields.ProductName, OrderDetailFields.SubTotal)
                .OrderByDesc(OrderDetailFields.OrderDate)
                .OrderBy(OrderDetailFields.ProductName)
                .ToList(0, 9);

            foreach (var od in orderDetails)
            {
                Console.WriteLine("{0}, {1},  {2}, {3}", od.OrderId, od.OrderDate, od.ProductName, od.SubTotal);
            }
        }