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, how can I achieve this query by LightSpeed Linq? Is it supported? SELECT * FROM [Table] WHERE Id IN (1, 2, 3, 4) Thanks |
|
|
Hi, yes this is supported. You would express this using one of these approaches:
Using LightSpeed Querying: var results = unitOfWork.Find<Table>(Entity.Attribute("Id").In(1, 2, 3, 4));
var results = unitOfWork.Table.Where(e => new int[4] { 1, 2, 3, 4 }.Contains(e.Id)).ToList();
Jeremy |
|
|
Aaha, thanks!
I tried method contains above the List<int> which is not working, so I thought that the method Contains is not supported. So if it could help to anybody:
List<int> listOfIDs = new List<int>(); unitOfWork.Table.Where(e => listOfIDs.Contains(e.Id)).ToList(); <-- Not working! unitOfWork.Table.Where(e => listOfIDs.ToArray().Contains(e.Id)).ToList(); <-- Working!
Thanks, Jeremy! |
|
|
Just to let you know, this limitation is resolved in the nightly builds: these will let you use the listOfIDs.Contains() syntax without needing the ToArray(). |
|
|
You are great guys! Though I have several topics about an enhancement to discuss, every day I thanks I have LightSpeed. |
|