我有简单对象
class SimpleObject
{
public int id { get; set;}
public System.DateTimeOffset timestamp { get; set; }
}
Controler中的方法
private dbEntities db = new dbEntities();
public object SaveSO()
{
SimpleObject so = new SimpleObject();
DateTimeOffset ts = DateTimeOffset.Now;
try
{
so.timestamp = ts;
db.SimpleObject.Add(so);
db.SaveChanges();
return View("index");
}
catch (Exception ex)
{
Debug.Write (ts + " ---> " + ex);
return View("index");
}
}
Controler在DB中保存对象,但时间为空。为什么呢?