I have a HashSet containing a list int int ids for items which must be selected.
HashSet<int> SelectedItems = new HashSet<int>()
The complete list of items is loaded by a LINQ to SQL statement.
I will be populating an ObservableCollection of the following:
public class DataItem
{
public int Id { get; private set; }
public name String { get; private set; }
public bool IsSelected { get; set; }
}
The IsSelected property must be set to true if the Id is in the HashSet, otherwise it must be set to false;
Here is my LINQ query:
var items =
from c in itemsContext.DataItems
where (c.Latest == true)
select c;
How can I join the HashSet into the above query to achieve the result I desire?
Thanks
PS: I am sorry but I do not know why the code blocks have been formatted incorrectly.
if i’m understanding your question properly i.e. dataitems corresponding to selecteditems in memmory…
Then use contains…