Update Core

This commit is contained in:
sunkaixuan 2017-07-17 13:03:56 +08:00
parent 55386d1dc2
commit b43f900b0d
10 changed files with 51 additions and 18 deletions

View File

@ -222,6 +222,10 @@ namespace SqlSugar
method = isNullableType ? getConvertInt32 : getInt32;
if (bindProperyTypeName.IsContainsIn("int64"))
method = isNullableType ? getConvertInt64 : getInt64;
if (bindProperyTypeName.IsContainsIn("byte"))
method = isNullableType ? getConvertByte : getByte;
if (bindProperyTypeName.IsContainsIn("int16"))
method = isNullableType ? getConvertInt16 : getInt16;
break;
case CSharpDataType.@bool:
if (bindProperyTypeName == "bool" || bindProperyTypeName == "boolean")

View File

@ -179,6 +179,7 @@ namespace SqlSugar
}
public virtual string GetAsString(string asName, string fieldValue)
{
if (fieldValue.Contains(".*")) return fieldValue;
return string.Format(" {0} {1} {2} ", GetTranslationColumnName(fieldValue), "AS", GetTranslationColumnName(asName));
}
@ -189,6 +190,7 @@ namespace SqlSugar
public virtual string GetAsString(string asName, string fieldValue, string fieldShortName)
{
if (fieldValue.Contains(".*")) return fieldValue;
return string.Format(" {0} {1} {2} ", GetTranslationColumnName(fieldShortName + "." + fieldValue), "AS", GetTranslationColumnName(asName));
}
public virtual void Clear()

View File

@ -6,7 +6,7 @@ using System.Text;
using System.Threading.Tasks;
namespace SqlSugar
{
public partial class DefaultDbMethod : IDbMethods
public partial class DefaultDbMethod : IDbMethods
{
public virtual string IIF(MethodCallExpressionModel model)
{
@ -273,7 +273,14 @@ namespace SqlSugar
public string GuidNew()
{
return "'"+Guid.NewGuid()+"' ";
return "'" + Guid.NewGuid() + "' ";
}
public string GetSelfAndAutoFill(string shortName, bool isSingle)
{
if (isSingle) return "*";
else
return string.Format("{0}.*", shortName);
}
}
}

View File

@ -47,6 +47,7 @@ namespace SqlSugar
string AggregateMax(MethodCallExpressionModel model);
string AggregateCount(MethodCallExpressionModel model);
string MappingColumn(MethodCallExpressionModel model);
string GetSelfAndAutoFill(string shortName,bool isSingle);
string True();
string False();
string GuidNew();

View File

@ -95,5 +95,12 @@ namespace SqlSugar
public static TResult AggregateMax<TResult>(TResult thisValue) { throw new NotSupportedException("This method is not supported by the current parameter"); }
public static TResult AggregateCount<TResult>(TResult thisValue) { throw new NotSupportedException("This method is not supported by the current parameter"); }
public static TResult MappingColumn<TResult>(TResult oldColumnName,string newColumnName) { throw new NotSupportedException("This method is not supported by the current parameter"); }
/// <summary>
///Example: new NewT(){name=SqlFunc.GetSelfAndAutoFill(it)} Generated SQL it.*
/// </summary>
/// <typeparam name="TResult"></typeparam>
/// <param name="value"></param>
/// <returns></returns>
public static TResult GetSelfAndAutoFill<TResult>(TResult value) { throw new NotSupportedException("This method is not supported by the current parameter"); }
}
}

View File

@ -67,6 +67,7 @@ namespace SqlSugar
{
case ResolveExpressType.WhereSingle:
case ResolveExpressType.WhereMultiple:
Check.Exception(name == "GetSelfAndAutoFill", "SqlFunc.GetSelfAndAutoFill can only be used in Select.");
Where(parameter, isLeft, name, args, model);
break;
case ResolveExpressType.SelectSingle:
@ -111,21 +112,29 @@ namespace SqlSugar
private void Select(ExpressionParameter parameter, bool? isLeft, string name, IEnumerable<Expression> args, MethodCallExpressionModel model, List<MethodCallExpressionArgs> appendArgs = null)
{
foreach (var item in args)
if (name == "GetSelfAndAutoFill")
{
var isBinaryExpression = item is BinaryExpression || item is MethodCallExpression;
if (isBinaryExpression)
{
model.Args.Add(GetMethodCallArgs(parameter, item));
}
else
{
Default(parameter, model, item);
}
var memberValue = (args.First() as MemberExpression).Expression.ToString();
model.Args.Add(new MethodCallExpressionArgs() { MemberValue= memberValue, IsMember=true, MemberName= memberValue });
}
if (appendArgs != null)
else
{
model.Args.AddRange(appendArgs);
foreach (var item in args)
{
var isBinaryExpression = item is BinaryExpression || item is MethodCallExpression;
if (isBinaryExpression)
{
model.Args.Add(GetMethodCallArgs(parameter, item));
}
else
{
Default(parameter, model, item);
}
}
if (appendArgs != null)
{
model.Args.AddRange(appendArgs);
}
}
parameter.BaseParameter.CommonTempData = GetMdthodValue(name, model);
}
@ -269,6 +278,9 @@ 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 "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);
default:
break;
}

View File

@ -17,5 +17,5 @@ using System.Runtime.InteropServices;
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("1c022a5c-4e4d-4026-a8a3-f659b9740a1a")]
[assembly: AssemblyVersion("4.2.0.9")]
[assembly: AssemblyFileVersion("4.2.0.9")]
[assembly: AssemblyVersion("4.2.1")]
[assembly: AssemblyFileVersion("4.2.1")]

View File

@ -2,7 +2,7 @@
<package >
<metadata>
<id>sqlSugarCore</id>
<version>4.2.0.9</version>
<version>4.2.1</version>
<authors>sunkaixuan</authors>
<owners>Landa</owners>
<licenseUrl>http://www.apache.org/licenses/LICENSE-2.0.html</licenseUrl>

View File

@ -8,6 +8,6 @@ namespace OrmTest
{
public class Config
{
public static string ConnectionString = @"DataSource=F:\MyOpenSource\SqlSugar4.XNew\SqlSugar\Src\Asp.NetCore\SqlServerTest\src\SqliteTest\DataBase\SqlSugar4xTest.sqlite";
public static string ConnectionString = @"DataSource=D:\MyGit\SqlSugar\Src\Asp.NetCore\SqlServerTest\src\SqliteTest\DataBase\SqlSugar4xTest.sqlite";
}
}