title: Update a property only when the new value is different from the current value
body: <p>I have a situation where I am updating a large amount of content in a CMS (Sitecore) overnight in which I have to iterate through a very large amount of data but with only a few updates to be applied (Approximately 320,000 potential fields, and at a guess maybe 3000 where the values actually change).  I want to streamline this so that updates are only made when the new value is different to the current value.  In this way I hope to minimise the amount of re-indexing that occurs after the updates are made, and also minimise the amount of content that subsequently gets published.</p>
  
  <p>This is an example of what I'm doing now</p>
  
  <pre><code>langItem.Fields["Type"].Value = updateNode.SelectSingleNode("./Type").InnerText;
  </code></pre>
  
  <p>And this is what I'm looking at changing it to</p>
  
  <pre><code>if (langItem.Fields["Type"].Value != updateNode.SelectSingleNode("./Type").InnerText)
      langItem.Fields["Type"].Value = updateNode.SelectSingleNode("./Type").InnerText;
  </code></pre>
  
  <p><strong>I feel like there should be some kind of operator that would take care of this for me.</strong>  I don't think there is but if there is please let me know what it is.  There are a lot of XPath queries (all my data is in XML) and I feel like repeating them is wasteful, but creating variables for all of them also seems like bad form.  Also, there are examples where the right-hand side involves a method call.  I think in those situations creating a variable for the result makes sense.</p>
  
  <p><strong>What are some other options for optimising this?</strong></p>