Link to home
Start Free TrialLog in
Avatar of rowmark
rowmark

asked on

Separating columnName and Value in C#

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
ASKER CERTIFIED SOLUTION
Avatar of jhshukla
jhshukla
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial