public User GetUser(Session session)
 {
     var users = from u in db.Users where u.id == session.id_user select u;
     if (users.Count() == 1)
         return (users).Single();
     return null;
 }
 public Session CreateSession(User user)
 {
     Session session = new Session()
     {
         id_user = user.id,
         session_key = Guid.NewGuid().ToString(),
         expire = DateTime.Now
     };
     db.Sessions.InsertOnSubmit(session);
     db.SubmitChanges();
     return GetSession(session.session_key);
 }
 partial void DeleteSession(Session instance);
 partial void UpdateSession(Session instance);
 partial void InsertSession(Session instance);
		private void detach_Sessions(Session entity)
		{
			this.SendPropertyChanging();
			entity.User = null;
		}
		private void attach_Sessions(Session entity)
		{
			this.SendPropertyChanging();
			entity.User = this;
		}