Update Core

This commit is contained in:
skx 2020-10-08 17:10:28 +08:00
parent b04bcc3002
commit aacc05ecb7
9 changed files with 45 additions and 8 deletions

View File

@ -29,8 +29,11 @@ namespace SqlSugar
csharpTypeName = "long";
if (csharpTypeName.ToLower().IsIn("boolean", "bool"))
csharpTypeName = "bool";
var mappings = this.MappingTypes.Where(it => it.Value.ToString().Equals(csharpTypeName, StringComparison.CurrentCultureIgnoreCase));
return mappings.HasValue() ? mappings.First().Key : "varchar";
var mappings = this.MappingTypes.Where(it => it.Value.ToString().Equals(csharpTypeName, StringComparison.CurrentCultureIgnoreCase)).ToList();
if (mappings!=null&&mappings.Count>0)
return mappings.First().Key;
else
return "varchar";
}
public string GetCsharpTypeName(string dbTypeName)
{

View File

@ -339,6 +339,10 @@ namespace SqlSugar
{
continue;
}
if (item.IsJson)
{
paramters.IsJson = true;
}
this.InsertBuilder.Parameters.Add(paramters);
}
}
@ -399,6 +403,10 @@ namespace SqlSugar
PropertyType = UtilMethods.GetUnderType(column.PropertyInfo),
TableId = i
};
if (column.IsJson)
{
columnInfo.IsJson = true;
}
if (columnInfo.PropertyType.IsEnum())
{
columnInfo.Value = Convert.ToInt64(columnInfo.Value);

View File

@ -162,7 +162,12 @@ namespace SqlSugar
pageIndex++;
batchInsetrSql.Append("\r\n;\r\n");
}
return batchInsetrSql.ToString();
var result= batchInsetrSql.ToString();
if (this.Context.CurrentConnectionConfig.DbType == DbType.SqlServer)
{
result += "select @@identity;";
}
return result;
}
}
public virtual object FormatValue(object value)

View File

@ -21,5 +21,6 @@ namespace SqlSugar
public object Value { get; set; }
public int DecimalDigits { get; set; }
public int Scale { get; set; }
internal bool IsJson { get; set; }
}
}

View File

@ -233,5 +233,6 @@ namespace SqlSugar
public string TypeName { get; set; }
public bool IsJson { get; set; }
}
}

View File

@ -43,7 +43,7 @@ namespace SqlSugar
var isDisableMasterSlaveSeparation = this.Context.Ado.IsDisableMasterSlaveSeparation;
this.Context.Ado.IsDisableMasterSlaveSeparation = true;
var count = Ado.ExecuteCommand(sql, InsertBuilder.Parameters == null ? null : InsertBuilder.Parameters.ToArray());
var result = (this.GetIdentityKeys().IsNullOrEmpty() || count == 0) ? 0 : Convert.ToInt64(GetSeqValue(GetSeqName()));
var result = (this.GetIdentityKeys().IsNullOrEmpty() || count == 0) ? 0 :Convert.ToInt64(GetSeqValue(GetSeqName()));
this.Context.Ado.IsDisableMasterSlaveSeparation = isDisableMasterSlaveSeparation;
return result;
}
@ -65,15 +65,15 @@ namespace SqlSugar
int seqBeginValue = 0;
seqBeginValue = this.Ado.GetInt("select " + seqName + ".Nextval from dual");
//Console.WriteLine(seqBeginValue);
var nextLength = insertCount - 1;
var nextLength= insertCount - 1;
if (nextLength > 0)
{
StringBuilder sb = new StringBuilder();
sb.AppendLine(" select " + seqName + ".nextval,t.* from (");
sb.AppendLine(" select "+ seqName + ".nextval,t.* from (");
for (int i = 0; i < nextLength; i++)
{
sb.AppendLine(" select 1 from dual");
if (i < (nextLength - 1))
if (i<(nextLength - 1) )
{
sb.AppendLine("union all");
}

View File

@ -6,6 +6,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Npgsql;
using NpgsqlTypes;
namespace SqlSugar
{
@ -94,6 +95,10 @@ namespace SqlSugar
sqlParameter.Value = parameter.Value;
sqlParameter.DbType = parameter.DbType;
sqlParameter.Direction = parameter.Direction;
if (parameter.IsJson)
{
sqlParameter.NpgsqlDbType = NpgsqlDbType.Json;
}
if (sqlParameter.Direction == 0)
{
sqlParameter.Direction = ParameterDirection.Input;

View File

@ -31,7 +31,7 @@ namespace SqlSugar
#region Common Methods
public override bool IsComplexModel(string sql)
{
return Regex.IsMatch(sql, @"AS \w+\.\w+");
return Regex.IsMatch(sql, @"AS ""\w+\.\w+""");
}
public override string ToSqlString()
{

View File

@ -7,5 +7,19 @@ namespace SqlSugar
{
public class SqlServerCodeFirst:CodeFirstProvider
{
protected override string GetTableName(EntityInfo entityInfo)
{
var table= this.Context.EntityMaintenance.GetTableName(entityInfo.EntityName);
var tableArray = table.Split('.');
var noFormat = table.Split(']').Length==1;
if (tableArray.Length > 1 && noFormat)
{
return tableArray.Last();
}
else
{
return table;
}
}
}
}