Add Json Index

This commit is contained in:
sunkaixuan 2023-10-22 12:43:01 +08:00
parent 4abd77972c
commit fb25e2da96
3 changed files with 12 additions and 1 deletions

View File

@ -716,6 +716,13 @@ namespace SqlSugar
{ {
return null; return null;
} }
public virtual string JsonIndex(MethodCallExpressionModel model)
{
var parameter = model.Args[0];
var parameter1 = model.Args[1];
return $"({parameter.MemberName}::json ->> {parameter1.MemberValue})";
}
public virtual string JsonField(MethodCallExpressionModel model) public virtual string JsonField(MethodCallExpressionModel model)
{ {

View File

@ -98,6 +98,7 @@ namespace SqlSugar
string Exists(MethodCallExpressionModel model); string Exists(MethodCallExpressionModel model);
string GetDateString(string dateValue,string format); string GetDateString(string dateValue,string format);
string GetForXmlPath(); string GetForXmlPath();
string JsonIndex(MethodCallExpressionModel model);
string JsonField(MethodCallExpressionModel model); string JsonField(MethodCallExpressionModel model);
string JsonContainsFieldName(MethodCallExpressionModel model); string JsonContainsFieldName(MethodCallExpressionModel model);
string JsonArrayLength(MethodCallExpressionModel model); string JsonArrayLength(MethodCallExpressionModel model);

View File

@ -113,7 +113,10 @@ namespace SqlSugar
{ {
throw new NotSupportedException("Can only be used in expressions"); throw new NotSupportedException("Can only be used in expressions");
} }
public static string JsonIndex(object json, int jsonIndex)
{
throw new NotSupportedException("Can only be used in expressions");
}
public static string JsonField(object json, string fieldName,string includeFieldName) public static string JsonField(object json, string fieldName,string includeFieldName)
{ {
throw new NotSupportedException("Can only be used in expressions"); throw new NotSupportedException("Can only be used in expressions");