We help IT Professionals succeed at work.
Get Started

Separating columnName and Value in C#

rowmark
rowmark asked
on
234 Views
Last Modified: 2013-12-17
hi, I have a employee object as shown below
class emp
    {
        public int EmpID { get; set; }
        public string EmpName { get; set; }
        public int deptID { get; set; }

    }

Open in new window


I need to create a mapping either in this class or a different class to map the properties with column name of my SQL
for eg. EmpdID="employeeID"
        EmpName="EmployeeName"
        deptID="DepartmentID"

Open in new window

for eg: emp e=new emp();
        e.EmpID=1;
        e.EmpName="tommy";    
        e.deptID=10;
When the emp object is populated and passed to the buildValues function it should return array of ComumnName(e.g.employeeID):Value(e.g.1),EmployeeName:tommy,DepartmentID:10)



string[] values=buildValues(emp);


public string[] buildValues(emp e)
{
  string[] values=null;


  return values;
}

Open in new window

I have 2 questions: 1. Where do I specify the mappings 2. How do I use the mappings in my buildValues function shown above and build the values string array.

I would really appreciate if you can help me with this
Comment
Watch Question
Commented:
This problem has been solved!
Unlock 1 Answer and 1 Comment.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE