public static IEnumerable <Order> BoundFunction(Db.OeBoundFunctionParameter <Customer, Order> boundParameter, IEnumerable <String> orderNames) { OrderContext orderContext = boundParameter.CreateDataContext <OrderContext>(); IQueryable <Customer> customers = boundParameter.ApplyFilter(orderContext.Customers, orderContext); IQueryable <Order> orders = customers.SelectMany(c => c.Orders).Where(o => orderNames.Contains(o.Name)); IQueryable result = boundParameter.ApplySelect(orders, orderContext); List <Order> orderList = boundParameter.Materialize(result).ToList().GetAwaiter().GetResult(); boundParameter.CloseDataContext(orderContext); return(orderList); }
public static IEnumerable <Order> BoundFunction(Db.OeBoundFunctionParameter <Customer, Order> boundParameter, IEnumerable <String> orderNames) { using (var orderContext = new OdataToEntityDB()) { IQueryable <Customer> customers = boundParameter.ApplyFilter(orderContext.Customers, orderContext); IQueryable <Order> orders = customers.SelectMany(c => c.Orders).Where(o => orderNames.Contains(o.Name)); IQueryable result = boundParameter.ApplySelect(orders, orderContext); List <Order> orderList = boundParameter.Materialize(result).ToListAsync().GetAwaiter().GetResult(); return(orderList); } }