Hi All,
I wanna update the specific property value by using reflection, and I used to iterate each row and update the value then finally submit to savechanges.
It takes some time to process all the things.
filter condition for fetch only required records
{
PropertyInfo _propertyName= orderToUpdate.GetType().GetProperty("CollumnName", BindingFlags.Public | BindingFlags.Instance | BindingFlags.IgnoreCase);
if( propertyName != null)
{
Type type = Nullable.GetUnderlyingType(prop.PropertyType) ?? prop.PropertyType;
object valueToUpdate = Convert.ChangeType(x.ColumnValue, type);
prop.SetValue(valueToUpdate , 1000, null);
}
}
_context.SaveChanges();There is any way to handle this bulk edit by using property reflection instead of checking each record property match.
Thanks,