This commit is contained in:
sunkaixuan
2017-01-30 15:19:34 +08:00
parent 5bdb68ffa3
commit 082aa697ce
6 changed files with 51 additions and 37 deletions

View File

@@ -0,0 +1,23 @@
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 partial class SqlServerExpressionContext : ExpressionContext
{
public SqlServerExpressionContext(Expression expression, ResolveExpressType resolveType) : base(expression, resolveType)
{
base.DbMehtods = new SqlServerMethod();
}
}
public partial class SqlServerMethod : DefaultDbMethod, IDbMethods
{
}
}

View File

@@ -1,34 +0,0 @@
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;
}
}
}
}

View File

@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SqlSugar
{
public partial class DefaultDbMethod : IDbMethods
{
public virtual 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;
}
}
}
}

View File

@@ -99,13 +99,14 @@
<Compile Include="Entities\DbTableInfo.cs" />
<Compile Include="ExpressionsToSql\Common\CommonTempDataType.cs" />
<Compile Include="ExpressionsToSql\Common\MethodCallExpressionModel.cs" />
<Compile Include="ExpressionsToSql\Databases\SqlServerExpressionContext.cs" />
<Compile Include="ExpressionsToSql\NBORM.cs" />
<Compile Include="ExpressionsToSql\Method\DefaultDbMethod.cs" />
<Compile Include="Databases\SqlServer\LambdaExpressions\SqlServerExpressionContext.cs" />
<Compile Include="ExpressionsToSql\Method\NBORM.cs" />
<Compile Include="ExpressionsToSql\Common\BinaryExpressionInfo.cs" />
<Compile Include="ExpressionsToSql\Common\ExpressionResult.cs" />
<Compile Include="ExpressionsToSql\Common\ExpressionErrorMessage.cs" />
<Compile Include="ExpressionsToSql\Common\ExpressionResultAcceptType.cs" />
<Compile Include="ExpressionsToSql\IDbMethods.cs" />
<Compile Include="ExpressionsToSql\Method\IDbMethods.cs" />
<Compile Include="ExpressionsToSql\ResolveItems\MemberConstExpressionResolve.cs" />
<Compile Include="ExpressionsToSql\ResolveItems\MemberInitExpressionResolve.cs" />
<Compile Include="ExpressionsToSql\ResolveItems\MemberNewExpressionResolve.cs" />