title: How to get list of Items with ids in NHibernate
body: <p>I have a list of item ids <code>playerIds</code> (they come from Redis),I Want to get Objects (<code>User</code>) of them through NHibernate , but the way i have written it is not optimized it think.</p>
  
  <p>here is my code :</p>
  
  <pre><code>List&lt;int&gt; playerIds = redisRespnse.Select(x =&gt; int.Parse(x)).ToList();
  using (var session = sessionFactory.OpenSession())
  {
      List&lt;User&gt; TopPlayers = new List&lt;User&gt;();
      for (int i = 0; i &lt; playerIds.Count; i++)
      {
          var player = session.Query&lt;User&gt;()
              .Where(user =&gt; user.Id == playerIds[i])
              .FirstOrDefault();
          if (player != null)
          {
              TopPlayers.Add(player);
          }
      }
      var finalResponse = new GetLeaderBoardResponse(TopPlayers);
      return Ok(finalResponse);
  }
  </code></pre>
  
  <p>Thanks.</p>