I have a function that looks like this:
public UpdateRecord(MyObjectModel TheObject, int TheUserID)
{
using (MyDataContextModel TheDC = new MyDataContextModel())
{
var TheObjectInDB = (from o in TheDC.TheObjects
where o.ObjectID == TheObject.ObjectID
select new MyObjectModel()).SingleOrDefault();
if (TheObject.Prop1 != null) { TheObjectInDB.Prop1 = TheObject.Prop1; }
if (TheObject.Prop2 != null) { TheObjectInDB.Prop2 = TheObject.Prop2; }
TheDC.SubmitChanges();
}
}
The code is not crashing but it's not updating the DB. What do I need to change?
TheObjectInDBreturns null?SELECTstatement to me, so why should it beUPDATEing the DB?