如何使用EF Core使用存储在JSON中的特定表和列更新数据

时间:2019-02-04 10:23:56

标签: c# .net-core ef-core-2.0

所以我想使用EF Core更新数据,但是我只想更新存储在JSON中的列。我可以这样做吗?

例如,我有这样的数据库:

+============+ 
|    tblA    | 
+============+ 
|     id     | 
+------------+ 
|    code    | 
+------------+ 
|    name    | 
+------------+
|    email   |
+------------+
|   address  |
+------------+


+============+ 
|    tblB    | 
+============+ 
|     id     | 
+------------+ 
|    colA    | 
+------------+ 
|    colB    | 
+------------+
|    colC    |
+------------+
|    colD    |
+------------+

,我的JSON将如下所示:

{
    "Entity": [
    {
      "TableName": "tblA",
      "Fields": [
        "name",
        "email",
        "address"
      ]
    },
    {
      "TableName": "tblB",
      "Fields": [
        "colC",
        "colD"
      ]
    }
  ]
}

作为JSON值,tblA将只能更新nameemailaddress。如果字段code或列表以外的其他内容没有变化。数据将不会更新。

那么有什么解决办法吗?

预先感谢

0 个答案:

没有答案