sql - Using entity framework and MSSQL AVG() function -
i have line of code (using mssql
):
double avg = db.mytable.where(x => x.recorddate < today).select(z => z.value).average();
i wonder if translated sql
avg()
function or average()
run on client side ?
this table contains 50,000 records per day , prefer let database calculate average , pass single value.
and, how can see sql
query sent database ?
if don't enumerate queryable
, yes, average
done on db side.
you can simplify code. select not needed, there's overload average taking expression<func<t, double>>
(or decimal, int...) parameter.
double avg = db.mytable.where(x => x.recorddate < today).average(z => z.value);
and quite many ways see sql generated, can google sql generated linq
, or take here, example
Comments
Post a Comment