Thursday, April 23, 2009

Simple nHibernate call to SQL GetDate

I needed to get the date from my SQL server. Found this worked fine.

public DateTime GetDate()
{
var session = GetCleanSession();
var query = session.CreateSQLQuery("SELECT Getdate();");
DateTime results = (DateTime)query.UniqueResult();

return results;
}

No comments: