Skip to content

Instantly share code, notes, and snippets.

@vkhorikov vkhorikov/1.cs
Last active Dec 5, 2017

What would you like to do?
NHibernate Async
Customer customer = await session.GetAsync<Customer>(1);
Customer customer = await session.LoadAsync<Customer>(1);
List<Customer> customers = await session.Query<Customer>().ToListAsync();
Customer customer = await session
.Where(x => x.Name.Contains("Customer 1"))
Customer customer = await session.CreateQuery("from Customer where Id = :Id")
.SetParameter("Id", 1)
Task<Customer> task1 = session.GetAsync<Customer>(1);
Task<Customer> task2 = session.GetAsync<Customer>(2);
Customer[] customers = await Task.WhenAll(task1, task2);
Customer customer1 = await session.GetAsync<Customer>(1);
Customer customer2 = await session.GetAsync<Customer>(2);
using (ISession session = sessionFactory.OpenSession())
using (ITransaction transaction = session.BeginTransaction())
Customer customer = await session.GetAsync<Customer>(1);
customer.Name = "Customer 3";
await session.SaveOrUpdateAsync(customer);
await transaction.CommitAsync();
List<Order> orders = await customer.Orders
.Where(x => x.Amount > 10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.