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
|
Hi! I'm having a problem with distinct operator in LINQ. I have the following table structure - WorkOrder has multiple WorkOrderTasks which have multiple Journals in it. I am trying to fetch distinct work order Id's but it seems not working. My build is from a week ago. Code> public IQueryable<WorkOrder> GetWorkOrders()
Result> 702 |
|
|
For some unknown reason this works:
public IQueryable<WorkOrder> GetWorkOrders() It gives distinct work orders... whatever, i doubt this is Lightspeed problem. Seems more like a LINQ problem. |
|
|
Hi milivojm, This occurs because of a limitation in the current version around using Distinct with associations. At present Distinct can only be used on the queried entity or its direct attributes e.g. // Distinct on a direct attribute - ContributorId // Distinct on an attribute of an association - Contributor . Id // Distinct on the association itself - Contributor As you have noted you can get around this by doing the Distinct() client-side, though this will have a performance impact if there are a lot of entities but relatively few distinct values. We hope to remove this limitation in a future version but we cannot currently commit to a timescale. Please let us know if it is a major issue for you so we can prioritise appropriately. |
|
|
No, it's fine. The workaround as satisfactory. Thank you. |
|