I want to find elements in which a search query exists within one of its subclauses
For example, I have a device with settings, I want a list of all devices that have DeviceSetting with Id=1and value.Contains("test"). I use LINQ to SQL, so if something can be done to save it quickly (and avoid projecting onto POCO), that would be great
How do I achieve this?
Device
{
List<DeviceSetting> Settings { get; set; }
}
DeviceSetting
{
int Id;
string value;
}
var devices = new List<Device>();
var search = "test";
var results = devices.Where(d => d.Settings.Contains(searchTerm));
Chris source
share