static void UserTicketLogic_Saving(UserEntity user)
 {
     if (!user.IsNew && user.IsGraphModified & user.InDBEntity(u => u.PasswordHash != user.PasswordHash))
         user.UserTickets().UnsafeDelete();
 }
        static int CleanExpiredTickets(UserEntity user)
        {
            DateTime min = TimeZoneManager.Now.Subtract(ExpirationInterval);

            int expired = user.UserTickets().Where(d => d.ConnectionDate < min).UnsafeDelete();

            int tooMuch = user.UserTickets().OrderByDescending(t => t.ConnectionDate).Skip(MaxTicketsPerUser).UnsafeDelete();

            return expired + tooMuch;
        }