title: Using reflection to check if a partial method has been implemented
body: <p><strong>Background</strong></p>
  
  <p>I am using Linq to SQL and thus have a generated DBML file containing auto-generated classes. Part of the generation process creates partial methods for certain actions, and in my case the two methods I am interested in related to the Insert and Update of table records. These partial methods are generated per each Table created in the DBML designer, for example:</p>
  
  <pre><code>partial void InsertMyTable(MyTable instance);
  partial void UpdateMyTable(MyTable instance);
  </code></pre>
  
  <p>Now part of the design of my application requires that these two partial methods are <strong>always</strong> implemented for every single table. (They are essentially used to add a timestamp to the record being inserted/updated).</p>
  
  <p><strong>Requirement</strong></p>
  
  <p>I have a unit test project, and although this may not be common practice I want to include a few tests that ensure certain things have been implemented properly. In this case I want to ensure that the developers have remembered to implement the partial methods mentioned above (I do NOT care about the actually implementation, only that they have been implemented).</p>
  
  <p><strong>Problem</strong></p>
  
  <p>What I need to do is use reflection to check if each partial method has been implemented, but I am having trouble working out how to determine that.</p>
  
  <p><strong>Attempted Efforts</strong></p>
  
  <p>So far I have managed to get a list of methods contained within the data context, and I am able to compare that with the methods expected for each table. The problem is that I can't find a way to determine if a given partial method actually has an implementation:</p>
  
  <pre><code>var methods = (typeof(MyDataContext)).GetMethods(BindingFlags.NonPublic | BindingFlags.Instance);
  foreach (var method in methods) 
  {
      Console.WriteLine(method.Name);
      //how to check if method is implemented, or just an unimplemented partial
  }
  </code></pre>