SqlSugar/SqlSugar/ExpressionsToSql/Databases/SqlServerExpressionContext.cs
2017-01-30 15:10:54 +08:00

35 lines
926 B
C#

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace SqlSugar
{
public class SqlServerExpressionContext : ExpressionContext
{
public SqlServerExpressionContext(Expression expression, ResolveExpressType resolveType) : base(expression, resolveType)
{
base.DbMehtods = new SqlServerMethod();
}
}
public class SqlServerMethod : IDbMethods
{
public string IsNullOrEmpty(MethodCallExpressionModel model)
{
var parameter = model.Args[0];
if (parameter.IsMember)
{
return string.Format("( {0}='' OR {0} IS NULL )", parameter.Value);
}
else
{
return null;
}
}
}
}