public int FindUsersByEmail(string emailToMatch, int pageIndex, int pageSize, MembershipUserCollection users, int counter)
        {
            using (var session = sessionFactory.OpenSession())
            {
                using (var trans = session.BeginTransaction())
                {
                    IList uList = session.CreateCriteria(typeof(User))
                                  .Add(Expression.Eq("EMail", emailToMatch))
                                  .Add(Expression.Eq("ApplicationName", _config.applicationName))
                                  .List();
                    int startIndex = pageSize * pageIndex;
                    int endIndex   = startIndex + pageSize - 1;

                    foreach (User u in uList)
                    {
                        if (counter >= startIndex)
                        {
                            users.Add(HelperObjects.GetUserFromObject(u, _config.providerName));
                        }
                        counter += 1;
                        if (counter > endIndex)
                        {
                            break;
                        }
                    }
                }
            }
            return(counter);
        }
 public MembershipUser GetUser(object userID, bool userIsOnline, MembershipUser membershipUser)
 {
     using (var session = sessionFactory.OpenSession())
     {
         using (var trans = session.BeginTransaction())
         {
             IList uList = session.CreateCriteria(typeof(User))
                           .Add(Expression.Eq("UserID", userID))
                           .Add(Expression.Eq("ApplicationName", _config.applicationName))
                           .List();
             if (uList.Count > 0)
             {
                 User u = (User)uList[0];
                 membershipUser = HelperObjects.GetUserFromObject(u, _config.providerName);
                 if (userIsOnline)
                 {
                     u.LastActivityDate = DateTime.Now;
                     trans.Commit();
                 }
             }
         }
     }
     return(membershipUser);
 }