The following LINQ to Entities query, a sub-query is performed and its results projected to MyViewModel
.
I am looking to obtain all ProjectedModel
objects with the myText
string variable in the Text
property of the SubModel
.
var items = (from t1 in db.MyTable
select new MyModel
{
Id = t1.MyId,
SomeItems = (from s1 in db.MyOtherTable
where s1.LinkedId == t1.Id
select new SubModel
{
Id = s1.Id,
Text = s1.Text
})
}).ToList();
Pseudo code would look like:
string myText = "abc";
items = items where SomeItems.Text contains myText