Search for orders in Commerce
# help-with-umbraco
i
@Matt Brailsford (HQ) I'm trying to search orders in Commerce using the fluent api, but keep getting an error. I've tried the following 3 ways to search:
Copy code
commerceOrders = _orderService.SearchOrders((where) => where
        .FromStore(store.Id)
        .And(where.IsFinalized())
        .And(where.HasProperty(Constants.Commerce.Properties.Customer.CsiAccountId, csiAccount.CsiAccountId)))
        .Items.ToList();

commerceOrders = _orderService.SearchOrders((where) => where
        .FromStore(store.Id)
        .And(where.IsFinalized())
        .And(where.HasProperty(Constants.Commerce.Properties.Customer.CsiAccountId, csiAccount.CsiAccountId)),
        currentPage: 1, itemsPerPage: int.MaxValue)
        .Items.ToList();

commerceOrders = _orderService.SearchOrders((where) => where
        .FromStore(store.Id)
        .And(where.IsFinalized())
        .And(where.HasProperty(Constants.Commerce.Properties.Customer.CsiAccountId, csiAccount.CsiAccountId)),
        (sort) => sort.ByFinalizedDate(),
        1, int.MaxValue)
        .Items.ToList();
each of these result in the following error: "Value cannot be null. (Parameter 'type')" at Umbraco.Commerce.Infrastructure.Resiliency.PollyExecutionStrategyBase.Execute[TResult](Func`1 operation, Func`1 verifySucceeded) at Umbraco.Commerce.Core.UmbracoCommerceUnitOfWorkProvider.Execute[T](IUnitOfWorkOptions options, Func`2 action) at Umbraco.Commerce.Core.UmbracoCommerceUnitOfWorkProvider.Execute[T](Boolean autoComplete, Func`2 action) at Umbraco.Commerce.Core.Services.OrderService.SearchOrders(IQuerySpecification`1 query, ISortSpecification`1 sort, Int64 currentPage, Int64 itemsPerPage) at Umbraco.Commerce.Core.Services.OrderService.SearchOrders(IQuerySpecification`1 query, Int64 currentPage, Int64 itemsPerPage) at Umbraco.Commerce.Core.Services.OrderService.SearchOrders(Func`2 query, Int64 currentPage, Int64 itemsPerPage)
9 Views