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 647897
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T21:46:24+00:00 2026-05-13T21:46:24+00:00

I have a situation where I am loading a very unnormalized record set from

  • 0

I have a situation where I am loading a very unnormalized record set from Excel. I pull in each row and create the objects from it one at a time. each row could contain a company and / or a client.

My issue is that multiple rows could have the same objects, so I may have already created it. I do a comparison to see if it is already in the list. If so I need to merge the two objects to ensure I have not gained any new information from the second row.

so:

company   - client   - address   - phone
----------------------------------------
mycompany -          - myaddress - 
mycompnay - myclient -           - myphone

so the first row would create a company object with an address of “myaddress”.
The second row would create another company object (which by my rules is the same company as the name is the same), this also having a client reference and a phone number.

So I would know they are the same but need to ensure all the data is merged into one object.

At the moment I am creating a utility class that takes both objects, (one being the primary and the other to be merged, so one has priority if there is a clash), it goes through each variable and assigns the values if there are any. This is a bit boiler plate heavy and I was hoping there might be some utility I could utilize to do the manual work for me.

The example has been simplified as there are a fair few other variables, some basic types and others that are more complex items.

  • 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-13T21:46:25+00:00Added an answer on May 13, 2026 at 9:46 pm

    Reflection would work. Something like:

    public static void MergeWith<T>(this T primary, T secondary) {
        foreach (var pi in typeof(T).GetProperties()) {
           var priValue = pi.GetGetMethod().Invoke(primary, null);
           var secValue = pi.GetGetMethod().Invoke(secondary, null);
           if (priValue == null || (pi.PropertyType.IsValueType && priValue.Equals(Activator.CreateInstance(pi.PropertyType)))) {
              pi.GetSetMethod().Invoke(primary, new object[]{secValue});
           }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a situation where I'm lazy loading images from the www. It's a
I have a situation where I'm loading some content using a URLLoader but the
I have recently come across a situation where code is dynamically loading some libraries,
I have a situation where I want to create a signature of a data
I have a situation where another developer is including source files from a project
We have a situation where users are allowed to upload content, and then separately
We have a situation in our product where for a long time some data
I have a situation where I might have multiple instances of a program running
I have the situation where i use GIS software which stores the information about
I have a situation where I have two entities that share a primary key

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.