I am using LINQ to Entities in an ASP.NET C# app. The below code is my attempt to update (or reset, really) a value ‘AvgRideTime’ in my sql db to null. However it seems to do nothing, no errors, just nothing. Any thoughts?
protected void ResetAvgRT_Click(object sender, EventArgs e)
{
using (RamRideOpsEntities myEntities = new RamRideOpsEntities())
{
var avgTime = (from a in myEntities.AdminOptions
select a.AvgRideTime).First();
if (avgTime != null)
{
avgTime = null;
myEntities.SaveChanges();
}
}
}
Try the above code.