title: Overriding Equals on IEquatable
body: <p>I have the following method which I am trying to use to stop people altering the <code>querystring</code> in order to view other peoples details:</p>
  
  <pre><code>public static bool IsCurrentUserAuthorisedVessel(HttpRequest request)
  {
      Guid currentUser = GetCurrentUserId();
      PersonRepository repo = new PersonRepository();
      VesselRepository vesselRepo = new VesselRepository();
  
      Person currentPerson = repo.GetPersonByUser(currentUser);
      int qs = int.Parse(request.QueryString["VesselId"]);
      Vessel currentVessel = vesselRepo.GetVessel(qs);
  
      if (!String.IsNullOrEmpty(request.QueryString["VesselId"]))
      {       
          if (IsCurrentUserAdmin())
          {
              return true;  //Always return true for admin                  
          }
          else
          {
              if (currentPerson.Vessels.Contains(currentVessel))
              {
                  return true;
              }
              else
                  return false;
          }                
      }
      return true;
  }
  </code></pre>
  
  <p>In the example I am currently debugging <code>currentPerson.Vessels</code> yields 3 vessels in an <code>Icollection&lt;Vessel&gt;</code> one of which has a <code>VesselId</code> of 6 which also happens to be the VesselId of <code>currentVessel</code> however the match is failing and the method is returning <code>false</code>.</p>
  
  <p>I have done some reading on similar SO questions and MSDN documentation and my understanding of what is happening here is because the Vessel which has an ID of 6 within the ICollection is a different instance of the currentVessel I am attempting to match, the reference is resulting in not equal and something to do with the equality rules are not based on ID.</p>
  
  <p>My <code>Person</code> model contains <code>public virtual ICollection&lt;Vessel&gt; Vessels { get; set; }</code> does this mean that I must implement the <code>IEquatable</code> interface on my <code>Vessel</code> model and then override the Equals method.</p>
  
  <p>I want my own custom rules based on id for equality in this instance. How do I override this method?</p>