dotnetcore / dotnetcore/FreeSql

json字段查询

Open
#1,881 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
4.4k
Forks
910
PR merge metrics
No merged PRs in 30d

Description

表达式树没有对应的json字段查询
https://freesql.net/guide/expression-function.html

例如下图ExtraProperties字段为json存储,json里对应的字段为Cpu,Ram,Price三个动态字段
![image](https://github.com/user-attachments/assets/a0136868-65c8-4e67-8499-2acd86a3084b)

declare @jsontable table(userName varchar(50),ExtraProperties varchar(max))
insert into @jsontable values('name1','{"Cpu":"Intel I7","Ram":"32GB","Price":"1999"}')
insert into @jsontable values('name2','{"Cpu":"Intel I3","Ram":"16GB","Price":"1699"}')
select * from @jsontable

例如要模糊搜索内存为32的数据行对应sql句语如下
select * from @jsontable where JSON_VALUE(ExtraProperties, N'$.Ram') LIKE '%32%'
![image](https://github.com/user-attachments/assets/37225c2b-381d-4508-afe4-a03940fa9651)

能否加入到SqlExt里面

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.