I want to query data from my table using JSON_VALUE
:
var str = "123";
var value = "Name"
using(var conn = GetMyConnection())
{
var result = conn.QueryFirstOrDefault<string>(
@"SELECT [Id] FROM [dbo].[MyTable]
WHERE JSON_VALUE([JsonColumn], @MyQuery) = @Str",
new
{
MyQuery = $"$.{value}",
Str = str
}
);
}
I try this in SQL Server, it is working:
SELECT [Id] FROM [dbo].[MyTable]
WHERE JSON_VALUE([JsonColumn], '$.Name') = '123'
How should I adjust my code?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…