Hi everyone! I am working on a project using NHibernate v.4 and i want to 
upgrade to v.5 to so that i can use Asynchonous function.But when i use 
async in my code, it doesnt return any result and stucked in await block. 
Here is my code without async
     public List<Folder> ListFolders()
        {
            var folders = new List<Folder>();

            var hashtableFolders = 
ContextPerRequest.Session.CreateCriteria(typeof(Folder).Name)
                                           .Add(Restrictions.Eq("State", 
(int)State.Active))
                                           .List<Hashtable>();

            foreach (var hashtableFolder in hashtableFolders)
            {
                var folder = 
_hashtableAdapter.HashtableToObject<Folder>(hashtableFolder);
                folders.Add(folder);
            }

            return folders;
        }

And here is my code use async 
 public async Task<List<Folder>> ListFoldersAsync()
        {
            var folders = new List<Folder>();

            var hashtableFolders = await 
ContextPerRequest.Session.CreateCriteria(typeof(Folder).Name)
                                           .Add(Restrictions.Eq("State", 
(int)State.Active))
                                           .ListAsync<Hashtable>();

            foreach (var hashtableFolder in hashtableFolders)
            {
                var folder = 
_hashtableAdapter.HashtableToObject<Folder>(hashtableFolder);
                folders.Add(folder);
            }

            return folders;
        }

And its usage
var folders = _adminService.ListFoldersAsync().Result;
Please help. Thanks you!

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/d/optout.

Reply via email to