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
Post a Comment