反序列化后SubmitChanges不起作用

时间:2019-06-03 13:27:07

标签: c# sql-server linq

我正在尝试按照下面的代码保存对象,但是没有引发错误,记录未插入表中。

VS 2017

using (MainDataContext db = new MainDataContext(model.ConnectionString))
    {
        Child kid = JsonConvert.DeserializeObject<Child>(JsonConvert.SerializeObject(model));
        kid.DTStamp = DateTime.Now;
        db.Child.InsertOnSubmit(kid);
        db.SubmitChanges();
        return new ApiResponse(System.Net.HttpStatusCode.OK) { ResponseMessage = "Child added successfully", ResponseObject = kid.ChildID };

    }

0 个答案:

没有答案