This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hey Guys I need help disecting this into a valid lightspeed query Say I have Customers (X) which have Orders (Y) which have Payments (P) I want to fetch all customers where there is at least one order where any payments on all orders have been marked as paid.
I just can't work out how to do this query. I tried Where(customer=>customer.Stutus="active"&&customer.orders.Count()>0&&customer.orders.All(order=>order.payments.any(payment=>payement.Paid=true))) but got an exception Unable to cast object of type 'Mindscape.LightSpeed.Querying.LiftedPathExpression' to type 'Mindscape.LightSpeed.Querying.PredicateExpression'. Any help?
Cheers Owen |
|
|
fogot to say i don't mind it not being in linq, a lightspeed query would be fine. |
|
|
Hi Owen,
Try using a query with joins rather than your current approach, e.g:
var customersWhoHaveOrdersThatArePaid = from c in unitOfWork.Customers join o in unitOfWork.Orders on c.Id == o.CustomerId join p in unitOfWork.Payments on o.Id == p.OrderId where p.Paid == true select c;
(Amend as needed for your model..)
Jeremy |
|
|
trouble with that is it doesn't tell me if the customer has any orders where there are no paid payments in which case the customer shouldn't be selected
IE i need the All operator to work, this will tell me where Any orders have a paid payment not where All orders have a paid payment O |
|
|
We think this is beyond what our query engine supports right now (even using the core engine rather than the LINQ provider). Unfortunately, all we can suggest at this stage is writing the raw SQL for the query, and using IUnitOfWork.FindBySql. Sorry. |
|