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

  • SEARCH
  • Home
  • 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 7196735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T20:50:05+00:00 2026-05-28T20:50:05+00:00

actually, I can make a relation between a table field and a variable by

  • 0

actually, I can make a relation between a table field and a variable by doing this inside my OE:

public class MyOE
{
  [Column("AGE_FIELD")]
  public int ageField { get; set; }
}

My OE class just need to use this other class:

[AttributeUsage(AttributeTargets.Property, Inherited = true, AllowMultiple = true)]
public class ColumnAtt : Attribute
{
  private string name;

  public string Name
  {
    get { return name; }
  }

  public ColumnAtt (string name)
  {
     this.name = name;
  }  
}

Well, using the code above, Im doing a generic method that I will need to get the “Column” value. How I could do that?

Here is my method:

public void CompareTwoObjectsAndSaveChanges<TObjectType>(TObjectType objectA, TObjectType objectB )
{
    if(objectA.GetType() == objectB.GetType())
    {
       foreach (var prop in objectA.GetType().GetProperties())
       {
           if(prop.GetValue(objectA, null) != prop.GetValue(objectB, null))
           {
               string colvalue  = "";//Here I need to get the Column value of the attribute.
               string nameOfPropertyThatChanges = prop.Name;
               string objectAValue = prop.GetValue(objectA, null).ToString();
               string objectBValue = prop.GetValue(objectB, null).ToString();

           }
       }   
    }
}
  • 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-28T20:50:05+00:00Added an answer on May 28, 2026 at 8:50 pm

    You need to use reflection to get the attributes applied to your object. If you know the attribute is always going to be ColumnAtt, then you can do something like this to get the value:

    public void CompareTwoObjectsAndSaveChanges<TObjectType>(TObjectType objectA, TObjectType objectB )
    {
        if(objectA.GetType() == objectB.GetType())
        {
           foreach (var prop in objectA.GetType().GetProperties())
           {
               if(prop.GetValue(objectA, null) != prop.GetValue(objectB, null))
               {
                   // Get the column attribute
                   ColumnAttr attr = (ColumnAttr)objectA.GetType().GetCustomAttributes(typeof(ColumnAttr), false).First();
    
                   string colValue = attr.Name;
                   string nameOfPropertyThatChanges = prop.Name;
                   string objectAValue = prop.GetValue(objectA, null).ToString();
                   string objectBValue = prop.GetValue(objectB, null).ToString();
               }
           }   
        }
    }
    

    This makes use of the GetCustomAttributes(...) method.

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

Sidebar

Related Questions

I've recently come across this website. Now, is there any way I can actually
I can't believe this - someone actually created two accounts on my social networking
I want to create a table where my users can associate a friendship between
I just noticed that you can make an XSS attack by using dashes between
According to this http://msdn.microsoft.com/en-us/library/cc849094(v=vs.85).aspx#OptInHighDPI you can make your web browser control use IE8-style zooming,
You can actually just skip this first part cause it gets confusing, but I'll
Actually I can save it in swf and in avi formats. Is there any
Last year, Scott Guthrie stated You can actually override the raw SQL that LINQ
I want to show up only words with minimum 4 Characters, actually I can
Is it at the state where it is actually useful and can do more

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.