Expression Support Guid.New

This commit is contained in:
sunkaixuan 2017-07-12 00:15:14 +08:00
parent a78a6ba2ed
commit 8afd7760b1
3 changed files with 14 additions and 3 deletions

View File

@ -270,5 +270,10 @@ namespace SqlSugar
{
return "( 1 = 2 ) ";
}
public string GuidNew()
{
return "'"+Guid.NewGuid()+"' ";
}
}
}

View File

@ -49,5 +49,6 @@ namespace SqlSugar
string MappingColumn(MethodCallExpressionModel model);
string True();
string False();
string GuidNew();
}
}

View File

@ -14,13 +14,18 @@ namespace SqlSugar
var express = base.Expression as MethodCallExpression;
var isLeft = parameter.IsLeft;
string methodName = express.Method.Name;
if (methodName == "get_Item") {
string paramterName =this.Context.SqlParameterKeyWord+ExpressionConst.Const + this.Context.ParameterIndex;
if (methodName == "get_Item")
{
string paramterName = this.Context.SqlParameterKeyWord + ExpressionConst.Const + this.Context.ParameterIndex;
this.Context.Parameters.Add(new SugarParameter(paramterName, ExpressionTool.DynamicInvoke(express)));
this.Context.Result.Append(string.Format(" {0} ",paramterName));
this.Context.Result.Append(string.Format(" {0} ", paramterName));
this.Context.ParameterIndex++;
return;
}
else if (methodName == "NewGuid") {
this.Context.Result.Append(this.Context.DbMehtods.GuidNew());
return;
}
var isValidNativeMethod = MethodMapping.ContainsKey(methodName)&&express.Method.DeclaringType.Namespace==("System");
if (!isValidNativeMethod&&express.Method.DeclaringType.Namespace.IsIn("System.Linq", "System.Collections.Generic")&&methodName=="Contains") {
methodName = "ContainsArray";