public bool AssociateExists(uint ownerid, uint associateid, Enum.AssociateType type)
 {
     using (var session = NHibernateHelper.OpenSession())
     {
         return(session
                .CreateCriteria <DbAssociate>()
                .Add(Restrictions.Eq("UID", ownerid))
                .Add(Restrictions.Eq("AssociateID", associateid))
                .Add(Restrictions.Eq("Type", (byte)type))
                .List <DbAssociate>().Count > 0);
     }
 }
        public void Remove(uint ownerid, uint associateid, Enum.AssociateType type)
        {
            DbAssociate rel;

            using (var session = NHibernateHelper.OpenSession())
            {
                rel = session
                      .CreateCriteria <DbAssociate>()
                      .Add(Restrictions.Eq("UID", ownerid))
                      .Add(Restrictions.Eq("AssociateID", associateid))
                      .Add(Restrictions.Eq("Type", (byte)type))
                      .UniqueResult <DbAssociate>();
            }
            ServerDatabase.Context.Associates.Remove(rel);
        }