I want to update a column which is dynamic. In my employee table i have various columns, which column to update depends on selection so it is dynamic.

In employee table, i have 5 columns - Id, name, desig, depart, Sal

So in case i have to update desig column :-

string columnName = "desig"; // This comes as a parameter. This is a dynamic Value. This is just an example.

var data = ctx.tblEmp.Where(e => e.Id == model.Id).Select(e => e).SingleOrDefault();

data.desig = 'NewValue';

ctx.tblEmp.Attach(data);
...
ctx.SaveChanges();

Related posts

Recent Viewed