mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-23 13:06:50 +08:00
Add Sqlfunc.CharIndex
This commit is contained in:
parent
91213483aa
commit
3d88df0e3d
@ -16,6 +16,17 @@ namespace OrmTest
|
||||
Async();
|
||||
NoEntity();
|
||||
Mapper();
|
||||
SqlFuncTest();
|
||||
}
|
||||
|
||||
private static void SqlFuncTest()
|
||||
{
|
||||
Console.WriteLine("");
|
||||
Console.WriteLine("#### SqlFunc Start ####");
|
||||
var db = GetInstance();
|
||||
var index= db.Queryable<Order>().Select(it => SqlFunc.CharIndex("a", "cccacc")).First();
|
||||
|
||||
Console.WriteLine("#### End Start ####");
|
||||
}
|
||||
|
||||
private static void Mapper()
|
||||
|
@ -353,5 +353,9 @@ namespace SqlSugar
|
||||
}
|
||||
return reslut.ToString();
|
||||
}
|
||||
public virtual string CharIndex(MethodCallExpressionModel model)
|
||||
{
|
||||
return string.Format("CHARINDEX ({0},{1})", model.Args[0].MemberName, model.Args[1].MemberName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -60,5 +60,6 @@ namespace SqlSugar
|
||||
string Null();
|
||||
string GetDate();
|
||||
string GetRandom();
|
||||
string CharIndex(MethodCallExpressionModel model);
|
||||
}
|
||||
}
|
||||
|
@ -118,5 +118,6 @@ namespace SqlSugar
|
||||
/// <returns></returns>
|
||||
public static Subqueryable<T> Subqueryable<T>() where T:class,new(){ throw new NotSupportedException("Can only be used in expressions");}
|
||||
public static CaseThen IF(bool condition) { throw new NotSupportedException("Can only be used in expressions"); }
|
||||
public static int CharIndex(string findChar,string searchValue) { throw new NotSupportedException("Can only be used in expressions"); }
|
||||
}
|
||||
}
|
||||
|
@ -585,6 +585,8 @@ namespace SqlSugar
|
||||
return this.Context.DbMehtods.GetDate();
|
||||
case "GetRandom":
|
||||
return this.Context.DbMehtods.GetRandom();
|
||||
case "CharIndex":
|
||||
return this.Context.DbMehtods.CharIndex(model);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -138,5 +138,10 @@ namespace SqlSugar
|
||||
{
|
||||
return "rand()";
|
||||
}
|
||||
|
||||
public override string CharIndex(MethodCallExpressionModel model)
|
||||
{
|
||||
return string.Format("instr ({0},{1})", model.Args[0].MemberName, model.Args[1].MemberName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -185,5 +185,10 @@ namespace SqlSugar
|
||||
{
|
||||
return "dbms_random.value";
|
||||
}
|
||||
|
||||
public override string CharIndex(MethodCallExpressionModel model)
|
||||
{
|
||||
return string.Format("instr ({0},{1},1,1) ", model.Args[0].MemberName, model.Args[1].MemberName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -221,5 +221,10 @@ namespace SqlSugar
|
||||
{
|
||||
return "RANDOM()";
|
||||
}
|
||||
|
||||
public override string CharIndex(MethodCallExpressionModel model)
|
||||
{
|
||||
throw new NotSupportedException("Slqite Not Supported CharIndex");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user