title: Invalid attempt to call IsDBNull when reader is closed
body: <p>I am trying to run query using Linq. Sometime query run successfully sometimes its giving me following error</p>
  
  <p>"Invalid attempt to call IsDBNull when reader is closed"</p>
  
  <p>I am not able to identify the root cause of this issue. If anyone knows about it please help me to solve this problem. 
  Any help would be highly appreciated.</p>
  
  <pre><code>lstitems = lstAllItems.Join(db.Users, i =&gt; i.UserId, u =&gt; u.UserID, (i, u) =&gt; new {
      i, u
  }).GroupJoin(db.UserProfile, u =&gt; u.u.UserID, up =&gt; up.UserID, (u, up) =&gt; new {
      u, up
  }).SelectMany(sm =&gt; sm.up.DefaultIfEmpty(), (sm, up) =&gt; new {
      sm, up
  })
      .AsEnumerable().Select(s =&gt; new ItemList {
      Title = s.sm.u.i.Title,
      UserId = s.sm.u.i.UserId,
      ItemId = s.sm.u.i.ItemId,
      RoomId = s.sm.u.i.RoomId,
      Description = s.sm.u.i.Description,
      OriginalImagePath = s.sm.u.i.OriginalImagePath,
      IdeaBookCount = db.IdeaBook.Where(o =&gt; o.UserId == s.sm.u.i.UserId &amp;&amp; o.IsDeleted == false).Select(x =&gt; x.IdeaBookId).Count(),
      OwnerUserId = s.sm.u.u.UserID,
      ownerIdStatus = s.sm.u.u.IdStatus,
      OwnerName = s.sm.u.u.UserType == (int) UserType.RenovateProfessional ? s.sm.u.u.CompanyName : s.sm.u.u.FirstName + " " + s.sm.u.u.LastName,
      OwnerUserName = s.sm.u.u.UserName,
      OwnerImg = s.sm.u.u.UserType == (int) UserType.RenovateProfessional ? Utilities.ImagePathForProfileForCompany(s.up == null || s.up.profileImg == null ? "" : s.up.profileImg) : Utilities.ImagePathForProfileForUser(s.up == null || s.up.profileImg == null ? "" : s.up.profileImg),
      OwnerCoverPic = s.sm.u.u.UserType == (int) UserType.RenovateProfessional ? Utilities.ImagePathForCoverImageForCompany(s.up == null || s.up.CoverImg == null ? "" : s.up.CoverImg) : Utilities.ImagePathForCoverImageForUser(s.up == null || s.up.CoverImg == null ? "" : s.up.CoverImg),
      OwnerPlace = s.sm.u.u.location == null ? "" : s.sm.u.u.location,
      IsContractor = s.sm.u.u.UserType == (int) UserType.RenovateProfessional ? true : false,
      OwnerNameHref = BaseUrl + (s.sm.u.u.UserType == (int) UserType.RenovateProfessional ? "Pro/" : "User/") + s.sm.u.u.UserName,
      CommentCount = db.ItemCounts.Where(u =&gt; u.ItemId == s.sm.u.i.ItemId).Select(x =&gt; x.CommentsCount).FirstOrDefault(),
      LikeCount = db.ItemCounts.Where(u =&gt; u.ItemId == s.sm.u.i.ItemId).Select(x =&gt; x.LikesCount).FirstOrDefault()
  }).ToList();
  </code></pre>