mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-20 02:29:39 +08:00
Synchronization code
This commit is contained in:
@@ -1192,5 +1192,35 @@ namespace SqlSugar
|
||||
var searchWord = mode.Args[1].MemberName;
|
||||
return $"to_tsvector('chinese', {columns}) @@ to_tsquery('chinese', {searchWord})";
|
||||
}
|
||||
|
||||
public virtual string PgsqlArrayContains(MethodCallExpressionModel model)
|
||||
{
|
||||
// 如果model.Args[1]是一个复杂类型,你可能需要将其转换为字符串或适当的格式
|
||||
// 在这里,我们假设它是一个可以直接转换为字符串的值
|
||||
string valueToFind = model.Args[1].MemberValue.ToString(); // 或者使用适当的转换方法
|
||||
var type = "text";
|
||||
if (model.Args[1].MemberValue is int)
|
||||
{
|
||||
type = "int4";
|
||||
}
|
||||
else if (model.Args[1].MemberValue is long)
|
||||
{
|
||||
type = "int8";
|
||||
}
|
||||
else if (model.Args[1].MemberValue is short)
|
||||
{
|
||||
type = "int2";
|
||||
}
|
||||
if (!UtilMethods.IsNumber(model.Args[1].MemberValue.GetType().Name))
|
||||
{
|
||||
valueToFind = $"'{valueToFind}'";
|
||||
}
|
||||
// PostgreSQL查询字符串
|
||||
string queryCondition = $"{model.Args[0].MemberName}::{type}[] @> ARRAY[{valueToFind}]";
|
||||
|
||||
// 如果需要处理NULL值或其他复杂情况,请在这里添加逻辑
|
||||
|
||||
return queryCondition;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -127,5 +127,6 @@ namespace SqlSugar
|
||||
string Ceil(MethodCallExpressionModel mode);
|
||||
string NewUid(MethodCallExpressionModel mode);
|
||||
string FullTextContains(MethodCallExpressionModel mode);
|
||||
string PgsqlArrayContains(MethodCallExpressionModel model);
|
||||
}
|
||||
}
|
||||
|
@@ -399,7 +399,10 @@ namespace SqlSugar
|
||||
{
|
||||
throw new NotSupportedException("Can only be used in expressions");
|
||||
}
|
||||
|
||||
public static bool PgsqlArrayContains(object jsonArray, object arrayValue)
|
||||
{
|
||||
throw new NotSupportedException("Can only be used in expressions");
|
||||
}
|
||||
public static bool JsonArrayAny(object jsonArray,object arrayValue)
|
||||
{
|
||||
throw new NotSupportedException("Can only be used in expressions");
|
||||
|
@@ -59,6 +59,7 @@ namespace SqlSugar
|
||||
if (ChildType == type|| (ChildType.IsInterface&&type.GetInterfaces().Contains(ChildType)))
|
||||
{
|
||||
var entityInfo = db.EntityMaintenance.GetEntityInfo(ChildType);
|
||||
this.Context.InitMappingInfo(ChildType);
|
||||
var exp = field.GetValue(item, null) as Expression;
|
||||
var whereStr = isWhere ? " AND " : " WHERE ";
|
||||
isWhere = true;
|
||||
|
Reference in New Issue
Block a user