【发布时间】:2021-01-09 11:53:03
【问题描述】:
我有一个实体,其中一个字符串字段我想使用 EF Core ExecuteSqlRawAsync 扩展存储 jsonstring(相当于 MyObject 列表的 json)。
但是,我收到了这个错误:
输入字符串的格式不正确。
来自英孚
Microsoft.EntityFrameworkCore.Storage.Internal.RawSqlCommandBuilder.Build.
我使用的是 EF Core 3.1 版。
请在下面找到类似于我正在尝试的示例概述:
string query = "update mytable set column1 = 100, column2= '[{\"property1\":\"value1\",\"property2\":null}]' where condition;update mytable set column1= 200, column2= '[{\"property1\":\"value2\",\"property\":null}]' where condition;"
await this.Context.Database.ExecuteSqlRawAsync(query);
如果我直接对 SQL Server 数据库运行相同的原始 SQL 语句,它就可以正常工作。
RawSql 扩展是否存在实体中的字符串字段不能有 jsonstring 的限制?
任何帮助如何使用包含 jsonstring 的字符串实体字段之一运行原始查询?
【问题讨论】:
标签: c# .net-core entity-framework-core