I have database which values that I want to search.
To search something, user needs to select specific checkboxes which value is contained in list in memory (otherwise any change value of checkbox would result saving database, what I want to avoid).
Data from my database are loaded by
.Load()
method.
So, my problem is that idk how to construct query which mix my database values with memory true/false values.
var query1 = from i in db.MyValuesTable
from j in MyMemoryObjects
where j.IsTrue && j.Id == i.Tab2Id && i.Value.Contains(_searchPhrase)
select i;
(from i in db.TableToLoad
from j in query1
where i.CollectionWithValues.Any(x => x.Tab1Id == j.Tab1Id && x.Tab2Id == j.Tab2Id).select i).Load();
My queries may be a bit confusing, so I'll put database schemes below (EF Code First)
//db object
public class MyValuesTable
{
public int Tab1Id { get; set; }
public int Tab2Id { get; set; }
public string Value { get; set; }
}
//memory object
public class MyMemoryObjects
{
public int Id { get; set; }
public bool IsTrue { get; set; }
}
//db object
public class TableToLoad
{
public int Tab1Id { get; set; }
public int Tab2Id { get; set; }
public string Value { get; set; }
}