HiRockstar8,
Use query like below.
NorthwindEntities entity = new NorthwindEntities();
var customers = entity.Customers.ToList();
var result = new List<Customer>();
var data = new Customer();
var type = data.GetType();
var columName = "CustomerID";
for (var i = 0; i < customers.Count; i++)
{
foreach (var property in data.GetType().GetProperties())
{
if (property.Name == columName)
{
type.GetProperties().FirstOrDefault(n => n.Name == property.Name)
.SetValue(data, GetPropValue(customers[i], property.Name), null);
result.Add(data);
}
}
}
GetPropValue
public static object GetPropValue(object src, string propName)
{
return src.GetType().GetProperty(propName).GetValue(src, null);
}