Is it possible to calculate Standard Deviation with NHibernate? I'm using the Microsoft SQL Server 2005 Dialect.
I can't find any examples of this anywhere.
Please help.
thanks!
Just wanted to let everyone know how I accomplished this with code that may help others:
When I create my SessionFactory, I simply add a custom SQL Function to the Configuration Object:
Setup:
var configuration = new Configuration();
configuration.AddSqlFunction("stdev", new StandardSQLFunction("stdev", HibernateUtil.Double));
SessionFactory = configuration.Configure().BuildSessionFactory();
Usage:
Then in my data provider I now can call the custom function:
ICriteria criteria = _session.CreateCriteria(typeof(ItemHistory));
criteria.SetProjection(Projections.SqlFunction("stdev", NHibernateUtil.Double, Projections.Property("Speed") ));
IList results = criteria.List();