Separating columnName and Value in C#
        Posted  
        
            by KungfuPanda
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by KungfuPanda
        
        
        
        Published on 2010-06-13T02:29:10Z
        Indexed on 
            2010/06/13
            2:42 UTC
        
        
        Read the original article
        Hit count: 374
        
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; }
    }
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"
When from my asp.net page when I create the employee class and pass it to a function:
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;
}
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
© Stack Overflow or respective owner