You're right. Thanks

Il giorno domenica 18 febbraio 2018 14:04:06 UTC+1, Gunnar Liljas ha 
scritto:
>
> You can ”return await .....ToListAsync”
>
> On 17 Feb 2018, at 22:31, Andrew <sbr...@gmail.com <javascript:>> wrote:
>
> Ok I found the problem. It's on my code. Maybe can help somebody this 
> solution.
>
> My wrong code:
>         public async Task<List<string>> GetList()
>         {
>             using (var session = _sessionFactory.OpenSession())
>             {
>                 return session.Query<MyTable>().Where(t => t.Visible == 
> true).OrderBy(t => t.Name).Select(t => t.Name).*ToListAsync*()
>             }
>         }
>
> Problem in this cose is in ToListAsync method that return Task that is not 
> yet processed, but session is closed immediately.
>
> This is correct code:
>
>         public async Task<List<string>> GetList()
>         {
>             using (var session = _sessionFactory.OpenSession())
>             {
>                 var result = await session.Query<MyTable>().Where(t => t.
> Visible == true).OrderBy(t => t.Name).Select(t => t.Name).ToListAsync()
>                 return result.ToList();
>             }
>         }
>
>
> -- 
> 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 nhusers+u...@googlegroups.com <javascript:>.
> To post to this group, send email to nhu...@googlegroups.com <javascript:>
> .
> Visit this group at https://groups.google.com/group/nhusers.
> For more options, visit https://groups.google.com/d/optout.
>
>

-- 
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 nhusers+unsubscr...@googlegroups.com.
To post to this group, send email to nhusers@googlegroups.com.
Visit this group at https://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/d/optout.

Reply via email to