hi, I'm trying to write the simplest db application using C#, ASP and
LINQtosQL but cannot get the Update function to work. I have used the
codemodel from a sample called IntroToLinq.
My Insert and Get functions work, but the Update does nothing. No
errors are thrown and no changes are made.
Here's my code
In the DBHelper class:
public static void Update<T>(T obj, Action<Tupdate) where T : class
{
using (var db = GetDatabaseData())
{
db.GetTable<T>().Attach(obj);
update(obj);
db.SubmitChanges();
}
}
public static void UpdateMyclass(Myclass iss)
{
Update<Myclass>(iss, delegate(Myclass i)
{
i.ID = iss.ID;
i.Description = iss.Description;
i.Status = iss.Status;
});
}
In my codebehind for the page where I want to save:
Myclass theObj = MyDB.GetObjById(TextBox1.Text);
theObj.Description = TextBox2.Text;
theObj .ID = TextBox1.Text;
try
{
MyDB.UpdateMyclass (theObj);
............etc.
What is missing in this code? Is there another easy (working..) way
to save this object in the DB using Linq?
THANKS!