c# - Entity framework use already selected value saved in new variable later in select sentance -


i wrote entity framework select:

var query = context.mytable    .select(a => new    {       count = a.othertable.where(b => b.id == id).sum(c => c.value),       total = a.othertable2.where(d => d.id == id) * count ...    }); 

i have select total:

var query = context.mytable    .select(a => new    {       count = a.othertable.where(b => b.id == id).sum(c => c.value),       total = a.othertable2.where(d => d.id == id) * a.othertable.where(b => b.id == id).sum(c => c.value)    }); 

is possible select in first example, because have retrieved value (and how that) or should select again?

one possible approach use 2 successive selects:

var query = context.mytable    .select(a => new    {       count = a.othertable.where(b => b.id == id).sum(c => c.value),       total = a.othertable2.where(d => d.id == id)    })    .select(x => new     {       count = x.count,       total = x.total * x.count    }; 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -