。Where(e => EF.Functions.JsonTypeof(e.Customer.GetProperty(“ Age”)))
https://www.npgsql.org/efcore/mapping/json.html?tabs=data-annotations%2Cjsondocument中的此语法无效!显示此错误:无法将“字符串”隐式转换为“布尔”
链接中的示例语法完全不完整。 JsonTypeof
根据链接映射到string
返回jsonb_typeof an]
将最外面的JSON值的类型作为文本字符串返回。可能的类型是对象,数组,字符串,数字,布尔值和null。
因此,
Where
子句中的正确示例用法将把方法的返回值与包含上述值之一的字符串进行比较
.Where(e => EF.Functions.JsonTypeof(e.Customer.GetProperty("Age")) == "number")