mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-07-31 15:56:25 +08:00
Update core
This commit is contained in:
parent
72a97b2342
commit
c65685dd43
@ -214,7 +214,7 @@ namespace SqlSugar
|
||||
internal string GetClassString(DbTableInfo tableInfo, ref string className)
|
||||
{
|
||||
string classText;
|
||||
var columns = this.Context.DbMaintenance.GetColumnInfosByTableName(tableInfo.Name);
|
||||
var columns = this.Context.DbMaintenance.GetColumnInfosByTableName(tableInfo.Name,false);
|
||||
if (this.Context.IgnoreColumns.HasValue())
|
||||
{
|
||||
var entityName = this.Context.EntityMaintenance.GetEntityName(tableInfo.Name);
|
||||
|
@ -337,15 +337,39 @@ namespace SqlSugar
|
||||
parameter.CommonTempData = CommonTempDataType.Result;
|
||||
this.Expression = expression.Expression;
|
||||
var isConst = this.Expression is ConstantExpression;
|
||||
var isDateTimeNowDateStartWith = expression.ObjToString().StartsWith("DateTime.Now.Date.");
|
||||
var isDateContains = expression.ObjToString().Contains(".Date.");
|
||||
if (this.Expression.Type == UtilConstants.DateType && this.Expression.ToString() == "DateTime.Now")
|
||||
{
|
||||
this.Expression = expression;
|
||||
var parameterName = base.AppendParameter(ExpressionTool.GetMemberValue(expression.Member, expression));
|
||||
base.AppendMember(parameter, isLeft, parameterName);
|
||||
}
|
||||
else if (isDateTimeNowDateStartWith)
|
||||
{
|
||||
this.Expression = expression;
|
||||
var parameterName = base.AppendParameter(ExpressionTool.GetMemberValue(expression.Member, expression));
|
||||
base.AppendMember(parameter, isLeft, parameterName);
|
||||
}
|
||||
else if (isDateContains)
|
||||
{
|
||||
parameter.CommonTempData = base.GetNewExpressionValue(this.Expression);
|
||||
var result = this.Context.DbMehtods.DateValue(new MethodCallExpressionModel()
|
||||
{
|
||||
Args = new List<MethodCallExpressionArgs>() {
|
||||
new MethodCallExpressionArgs() { IsMember = !isConst, MemberName = parameter.CommonTempData, MemberValue = null },
|
||||
new MethodCallExpressionArgs() { IsMember = true, MemberName = name, MemberValue = name }
|
||||
}
|
||||
});
|
||||
base.AppendMember(parameter, isLeft, result);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.Start();
|
||||
if(parameter.CommonTempData!=null&& parameter.CommonTempData is DateTime)
|
||||
{
|
||||
parameter.CommonTempData= base.AppendParameter(parameter.CommonTempData);
|
||||
}
|
||||
var result = this.Context.DbMehtods.DateValue(new MethodCallExpressionModel()
|
||||
{
|
||||
Args = new List<MethodCallExpressionArgs>() {
|
||||
|
@ -926,6 +926,26 @@ namespace SqlSugar
|
||||
{
|
||||
return $"strftime('%Y-%m-%d', {value})";
|
||||
}
|
||||
else if (IsSqlite() && formatString == "yyyy-MM-dd HH:mm:ss")
|
||||
{
|
||||
return $"strftime('%Y-%m-%d %H:%i:%S', {value})";
|
||||
}
|
||||
else if (IsSqlite() && formatString == "yyyy-MM-dd hh:mm:ss")
|
||||
{
|
||||
return $"strftime('%Y-%m-%d %H:%i:%S', {value})";
|
||||
}
|
||||
else if (IsSqlite() && formatString == "yyyy-MM")
|
||||
{
|
||||
return $"strftime('%Y-%m', {value})";
|
||||
}
|
||||
else if (IsSqlite() && formatString == "yyyyMM")
|
||||
{
|
||||
return $"strftime('%Y%m', {value})";
|
||||
}
|
||||
else if (IsSqlite() && formatString == "yyyyMMdd")
|
||||
{
|
||||
return $"strftime('%Y%m%d', {value})";
|
||||
}
|
||||
else if (IsSqlite() && formatString.Contains("%"))
|
||||
{
|
||||
return $"strftime('{formatString}', {value})";
|
||||
@ -934,6 +954,26 @@ namespace SqlSugar
|
||||
{
|
||||
return $"DATE_FORMAT({value}, '%Y-%m-%d')";
|
||||
}
|
||||
else if (IsMySql() && formatString == "yyyy-MM")
|
||||
{
|
||||
return $"DATE_FORMAT({value}, '%Y-%m')";
|
||||
}
|
||||
else if (IsMySql() && formatString == "yyyyMM")
|
||||
{
|
||||
return $"DATE_FORMAT({value}, '%Y%m')";
|
||||
}
|
||||
else if (IsMySql() && formatString == "yyyyMMdd")
|
||||
{
|
||||
return $"DATE_FORMAT({value}, '%Y%m%d')";
|
||||
}
|
||||
else if (IsMySql() && formatString == "yyyy-MM-dd HH:mm:ss")
|
||||
{
|
||||
return $"DATE_FORMAT({value}, '%Y-%m-%d %H:%i:%S')";
|
||||
}
|
||||
else if (IsMySql() && formatString == "yyyy-MM-dd hh:mm:ss")
|
||||
{
|
||||
return $"DATE_FORMAT({value}, '%Y-%m-%d %H:%i:%S')";
|
||||
}
|
||||
else if (IsMySql() && formatString.Contains("%"))
|
||||
{
|
||||
return $"DATE_FORMAT({value}, '{formatString}')";
|
||||
@ -1027,7 +1067,7 @@ namespace SqlSugar
|
||||
};
|
||||
foreach (var r in strings)
|
||||
{
|
||||
if (r.Substring(0, 1) == "@")
|
||||
if (r!=""&&r.Substring(0, 1) == "@")
|
||||
{
|
||||
joinStringParameter.Args.Add(new MethodCallExpressionArgs()
|
||||
{
|
||||
|
@ -408,14 +408,18 @@ namespace SqlSugar
|
||||
var jsonString = readerValues.First(it => it.Key.EqualCase(key)).Value;
|
||||
if (jsonString != null)
|
||||
{
|
||||
if (jsonString.ToString().First() == '{'&& jsonString.ToString().Last() == '}')
|
||||
if (jsonString.ToString().First() == '{' && jsonString.ToString().Last() == '}')
|
||||
{
|
||||
result.Add(name, this.DeserializeObject<Dictionary<string, object>>(jsonString + ""));
|
||||
}
|
||||
else if (jsonString.ToString().Replace(" ","")!="[]"&&!jsonString.ToString().Contains("{")&&!jsonString.ToString().Contains("}"))
|
||||
{
|
||||
result.Add(name, this.DeserializeObject<dynamic>(jsonString + ""));
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
result.Add(name, this.DeserializeObject<List<Dictionary<string, object>>>(jsonString + ""));
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -395,6 +395,14 @@ namespace SqlSugar
|
||||
public override bool CreateTable(string tableName, List<DbColumnInfo> columns, bool isCreatePrimaryKey = true)
|
||||
{
|
||||
tableName = this.SqlBuilder.GetTranslationTableName(tableName);
|
||||
foreach (var item in columns)
|
||||
{
|
||||
if (item.DataType == "decimal" && item.DecimalDigits == 0 && item.Length == 0)
|
||||
{
|
||||
item.DecimalDigits = 4;
|
||||
item.Length = 18;
|
||||
}
|
||||
}
|
||||
string sql = GetCreateTableSql(tableName, columns);
|
||||
this.Context.Ado.ExecuteCommand(sql);
|
||||
if (isCreatePrimaryKey)
|
||||
|
Loading…
Reference in New Issue
Block a user