This commit is contained in:
sunkaixuan
2017-09-03 01:46:56 +08:00
parent ee4878a983
commit 47e0f1007d
4 changed files with 24 additions and 1 deletions

View File

@@ -74,10 +74,25 @@ namespace OrmTest.UnitTest
Replace();
Length();
Time();
Test1();
}
base.End("Method Test");
}
private void Test1()
{
var ids = new int[] { 1, 2, 3 };
Expression<Func<Student, bool>> exp = it => ids.Contains(it.Id)&&!SqlFunc.IsNullOrEmpty(it.Name);
SqlServerExpressionContext expContext = new SqlServerExpressionContext();
expContext.Resolve(exp, ResolveExpressType.WhereSingle);
var value = expContext.Result.GetString();
var pars = expContext.Parameters;
base.Check(value, pars, "(([Id] IN ('1','2','3')) AND NOT( [Name]='' OR [Name] IS NULL ))", new List<SugarParameter>() {
}, "Test1 error");
}
private void ExtendToString()
{
Expression<Func<Student, bool>> exp = it => it.Id.ToString() == "a";

View File

@@ -52,6 +52,12 @@ namespace SqlSugar
_Result = value;
}
}
public bool LastCharIsSpace{
get {
if (_Result == null|| _Result.Length==0) return true;
return _Result.ToString().Last() == UtilConstants.SpaceChar;
}
}
#endregion
public string GetString()
{

View File

@@ -239,9 +239,10 @@ namespace SqlSugar
protected void AppendNot(object Value)
{
var isAppend = !this.Context.Result.Contains(ExpressionConst.FormatSymbol);
var lastCharIsSpace = this.Context.Result.LastCharIsSpace;
if (isAppend)
{
this.Context.Result.Append("NOT");
this.Context.Result.Append(lastCharIsSpace?"NOT":" NOT");
}
else
{

View File

@@ -9,6 +9,7 @@ namespace SqlSugar
public const string Dot = ".";
public const char DotChar = '.';
internal const string Space = " ";
internal const char SpaceChar =' ';
internal const string AssemblyName = "SqlSugar";
internal const string ReplaceKey = "{662E689B-17A1-4D06-9D27-F29EAB8BC3D6}";