I have and entity model as follows.
public class reg{
public int id {get; set;}
...
public ICollection<trans> trans{get; set;}
}
public class trans{
public int id {get; set;}
...
public modifiedTrans modifiedTrans{get; set;}
public virtual reg reg {get; set;}
}
public class modifiedTrans {
public int id {get; set;}
...
public virtual trans trans {get; set;}
}
I need a linq expression which gives me the result filtered by reg id as
{
id : x
...
trans : {
id : y1,
...,
modifiedTrans : {
id : z1
...
}
},
{
id : y2,
...,
modifiedTrans : {
id : z2
...
}
}
}
So far I ended up like this:
var query = from r in reg
let t = r.trans
let m = t.modifiedTrans
where (r => r.Id = 1)
select new
{
r = r,
t = t,
m = m
}.FirstOrDefault();
which is not really I would like to have. Can anyone please help!!