mardi 20 janvier 2015

SetValue on Linq2Sql Object

Is it possible to use reflection or expressions to modify a Linq2Sql object? As a simple example that will not work:



MyDataClassDataContext db = new MyDataClassDataContext();
var actionData = (from ac in db.Actions where ac.ActionID == action.ActionID select ac).First();
var property = typeof(Action).GetProperty("ActionID");
property.SetValue(33, actionData);

...

db.SubmitChanges();
db.Dispose();





Aucun commentaire:

Enregistrer un commentaire