mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-19 18:22:23 +08:00
Add SqlFunc.IsNull
This commit is contained in:
@@ -433,6 +433,7 @@ namespace OrmTest.Demo
|
||||
{
|
||||
var db = GetInstance();
|
||||
var t1 = db.Queryable<Student>().Where(it => SqlFunc.ToLower(it.Name) == SqlFunc.ToLower("JACK")).ToList();
|
||||
var t2 = db.Queryable<Student>().Where(it => SqlFunc.IsNull(it.Name,"nullvalue")=="nullvalue").ToList();
|
||||
//SELECT [Id],[SchoolId],[Name],[CreateTime] FROM [Student] WHERE ((LOWER([Name])) = (LOWER(@MethodConst0)) )
|
||||
|
||||
/***More Functions***/
|
||||
|
@@ -271,6 +271,13 @@ namespace SqlSugar
|
||||
return string.Format("{0}", parameter1.MemberValue);
|
||||
}
|
||||
|
||||
public virtual string IsNull(MethodCallExpressionModel model)
|
||||
{
|
||||
var parameter = model.Args[0];
|
||||
var parameter1 = model.Args[1];
|
||||
return string.Format("ISNULL({0},{1})",parameter.MemberName,parameter1.MemberName);
|
||||
}
|
||||
|
||||
public virtual string True()
|
||||
{
|
||||
return "( 1 = 1 ) ";
|
||||
|
@@ -48,6 +48,7 @@ namespace SqlSugar
|
||||
string AggregateMax(MethodCallExpressionModel model);
|
||||
string AggregateCount(MethodCallExpressionModel model);
|
||||
string MappingColumn(MethodCallExpressionModel model);
|
||||
string IsNull(MethodCallExpressionModel model);
|
||||
string GetSelfAndAutoFill(string shortName,bool isSingle);
|
||||
string True();
|
||||
string False();
|
||||
|
@@ -67,6 +67,7 @@ namespace SqlSugar
|
||||
public static int DateValue(DateTime date, DateType dataType) { throw new NotSupportedException("Can only be used in expressions"); }
|
||||
public static bool Between(object value, object start, object end) { throw new NotSupportedException("Can only be used in expressions"); }
|
||||
public static TResult IIF<TResult>(bool Expression, TResult thenValue, TResult elseValue) { throw new NotSupportedException("Can only be used in expressions"); }
|
||||
public static TResult IsNull<TResult>(TResult thisValue, TResult ifNullValue) { throw new NotSupportedException("Can only be used in expressions"); }
|
||||
public static int ToInt32(object value) { return value.ObjToInt(); }
|
||||
public static long ToInt64(object value) { return Convert.ToInt64(value); }
|
||||
/// <summary>
|
||||
|
@@ -407,6 +407,8 @@ namespace SqlSugar
|
||||
Check.Exception(!isValid, "SqlFunc.MappingColumn parameters error, The property name on the left, string value on the right");
|
||||
this.Context.Parameters.RemoveAll(it => it.ParameterName == model.Args[1].MemberName.ObjToString());
|
||||
return mappingColumnResult;
|
||||
case "IsNull":
|
||||
return this.Context.DbMehtods.IsNull(model);
|
||||
case "GetSelfAndAutoFill":
|
||||
this.Context.Parameters.RemoveAll(it => it.ParameterName == model.Args[0].MemberName.ObjToString());
|
||||
return this.Context.DbMehtods.GetSelfAndAutoFill(model.Args[0].MemberValue.ObjToString(), this.Context.IsSingle);
|
||||
|
Reference in New Issue
Block a user