Q: Loop through strongly type fields Entity Framework c# I am trying to come up with a neat solution for this problem to make it scalable. I've got a DataTable dt, which has its structure read from a database. I want to be able to correctly map this data into the correct fields using Entity Framework and allow the code to function even if columns are added or deleted. 
using (Entities db = new Entities())
{
    foreach (DataRow dr in dt.Rows)
    {
        var result = db.myTable.SingleOrDefault(e => e.Email == dr["Email"].ToString());

        foreach (SourceToDestinationMapping s in mapping)
        {
            // want to do something like this
            result[s.DestinationColumn] = dt[s.DestinationColumn];

           // instead of this
           result.Name = dt["Name"].ToString();
           result.Address = dt["Address"].ToString();
           // all field mappings
        }
    }
}

Is this something that is possible to do? Or do I need to make code changes every time a new column gets added/removed? If this isn't something that works then I can switch to doing something like this without Entity Framework.
Edit:
Example would be:
1, EmailAddress, Email, 1
public partial class SourceToDestinationMapping
{
    public int MappingId { get; set; }
    public string SourceColumn { get; set; }
    public string DestinationColumn { get; set; }
    public bool Active { get; set; }
}


A: Since Entity Framework works with objects you'd need to use reflection to get and set properties without knowing which properties you need to operate on, and it can get pretty complicated if you have many types that you need to handle. So basically examine the type of the object you're looking at, get its list of properties, and search for columns with the same name as the property (or some other convention you have) in the data table row. But again, you'll need to handle the type conversions, if the property is an int you need to get the cell value as an int etc.
