fastest way to compare 2 objects excluding a few properties?
<p>I have a site where users upload data into it and I only want to update data where properties have been changed.  So I am comparing 2 objects of the same type for changes and I need to exclude a few properties such as ModifiedOn which is a date.  </p>

<p>Here is my code thus far using reflection:</p>

<pre><code> private bool hasChanges(object OldObject, object newObject)
        {
            var oldprops = (from p in OldObject.GetType().GetProperties() select p).ToList();
            var newprops = (from p in newObject.GetType().GetProperties() select p).ToList();
            bool isChanged = false;
            foreach (PropertyInfo i in oldprops)
            {
                if (checkColumnNames(i.Name))
                {
                    var newInfo = (from x in newprops where x.Name == i.Name select x).Single();
                    var oldVal = i.GetValue(OldObject, null);
                    var newVal = newInfo.GetValue(newObject, null);

                    if (newVal == null || oldVal == null)
                    {
                        if (newVal == null &amp;&amp; oldVal != null)
                        {
                            isChanged = true;
                            return true;
                        }
                        if (oldVal == null &amp;&amp; newVal != null)
                        {
                            isChanged = true;
                              return true;
                        }
                    }
                    else
                    {
                        if (!newVal.Equals(oldVal))
                        {
                            isChanged = true;
                         return true;
                        }
                    }
                }
            }

            return isChanged;
        }
</code></pre>

<p>I ignore certain columns with this method: </p>

<pre><code>private bool checkColumnNames(string colName)
        {
            if (
                colName.ToLower() == "productid" ||
                colName.ToLower() == "customerid" ||
                colName.ToLower() == "shiptoid" ||
                colName.ToLower() == "parentchildid" ||
                colName.ToLower() == "categoryitemid" ||
                 colName.ToLower() == "volumepricingid" ||
                colName.ToLower() == "tagid" ||
                colName.ToLower() == "specialprice" ||
                colName.ToLower() == "productsmodifierid" ||
                colName.ToLower() == "modifierlistitemid" ||
                colName.ToLower() == "modifierlistid" ||
                colName.ToLower() == "categoryitemid" ||
                colName.ToLower() == "createdon" ||
                colName.ToLower() == "createdby" ||
                colName.ToLower() == "modifiedon" ||
                colName.ToLower() == "modifiedby" ||
                colName.ToLower() == "deletedon" ||
                colName.ToLower() == "deletedby" ||
                colName.ToLower() == "appendproductmodifiers" ||
                colName.ToLower() == "introdate" ||
                colName.ToLower() == "id" ||
                colName.ToLower() == "discontinued" ||
                colName.ToLower() == "stagingcategories"
                )
                return false;

            return true;
        }
</code></pre>

<p>This has been working very well except for now I have users comparing 50,000+ items in a single upload which is taking a really long time.</p>

<p>Is there a faster way to accomplish this?</p>
