Is there any way to have LINQ translate queries directly to functions like SQL's STDEV
? For example, the LINQ
from t in table
group t by t.something into g
select new {
avg = g.Average(o => o.number)
stdev = g.?????
}
gets turned into a SQL AVG
. However, there is no support for standard deviation in LINQ.
One approach was suggested here: Standard Deviation in LINQ
However, this is clunky and it also requires a bit of additional work to handle possible null values, which the sql STDEV
function automatically ignores for you. Additionally, it results in less data being sent over the wire and it's faster to compute.
Any way to do this?