With all the fuzz about .NET Core I almost forgot that NHibernate 5 was released a month ago.
One the things I was waiting for was the introduction of async/await to optimize IO bound methods. And after waiting for a loooooong time it’s finally there:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Usage ICriteria.ListAsync<T>() | |
var customers = await session.CreateCriteria<Customer>().ListAsync<Customer>(); | |
// Usage ICriteria.UniqueResultAsync<T>() | |
var customer = await session | |
.CreateCriteria<Customer>() | |
.Add(Restrictions.Eq("Name", "Ayende")) | |
.UniqueResultAsync<Customer>(); | |
// Usage IQueryOver.ListAsync() | |
var person = await session.QueryOver<Customer>().ListAsync(); | |
// Usage IQueryOver.ListAsync<T>() | |
var person = await session.QueryOver<Customer>().Select(p => p.Name).ListAsync<string>(); | |
// Usage IQueryOver.SingleOrDefaultAsync<T>() | |
var customer = await session.QueryOver<Customer>().SingleOrDefaultAsync(); | |
//Usage of ISession.FlushAsync() | |
_session.FlushAsync(cancellationToken); |