Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7624213
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T04:54:15+00:00 2026-05-31T04:54:15+00:00

I have a site where users upload data into it and I only want

  • 0

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.

Here is my code thus far using reflection:

 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 && oldVal != null)
                        {
                            isChanged = true;
                            return true;
                        }
                        if (oldVal == null && newVal != null)
                        {
                            isChanged = true;
                              return true;
                        }
                    }
                    else
                    {
                        if (!newVal.Equals(oldVal))
                        {
                            isChanged = true;
                         return true;
                        }
                    }
                }
            }

            return isChanged;
        }

I ignore certain columns with this method:

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;
        }

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.

Is there a faster way to accomplish this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T04:54:16+00:00Added an answer on May 31, 2026 at 4:54 am

    It would certainly be faster if you just used reflection to create and compile a method using the above logic. This should be much faster than reflecting on each object.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want my site to have a feature for users to upload images, but
We are designing a web-site allowing business to upload data via XML. We have
We have a site where users upload files, some of them quite large. We've
I have a social networking site where users update their moods, profiles and add
I have a site where users can post stuff (as in forums, comments, etc)
I have a site where users can log in and check on outstanding support
Let's say I have a site where Users can add Entries through admin panel.
I have a site that allows users to copy and paste the embeded video
I have a site where some users will be registered by our staff, and
I currently have a site where different users can login, and depending on their

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.