Update Core

This commit is contained in:
skx
2020-04-21 15:57:08 +08:00
parent 6a50885e27
commit 2e4a984564
5 changed files with 33 additions and 6 deletions

View File

@@ -311,7 +311,8 @@ namespace SqlSugar
sqlCommand.Parameters.Clear(); sqlCommand.Parameters.Clear();
ExecuteAfter(sql, parameters); ExecuteAfter(sql, parameters);
SetConnectionEnd(sql); SetConnectionEnd(sql);
//sqlCommand.Dispose(); if (this.Context.CurrentConnectionConfig.DbType == DbType.Sqlite)
sqlCommand.Dispose();
return sqlDataReader; return sqlDataReader;
} }
catch (Exception ex) catch (Exception ex)
@@ -445,7 +446,8 @@ namespace SqlSugar
sqlCommand.Parameters.Clear(); sqlCommand.Parameters.Clear();
ExecuteAfter(sql, parameters); ExecuteAfter(sql, parameters);
SetConnectionEnd(sql); SetConnectionEnd(sql);
//sqlCommand.Dispose(); if (this.Context.CurrentConnectionConfig.DbType == DbType.Sqlite)
sqlCommand.Dispose();
return sqlDataReader; return sqlDataReader;
} }
catch (Exception ex) catch (Exception ex)

View File

@@ -191,16 +191,28 @@ namespace SqlSugar
public IDeleteable<T> Where(string whereString, SugarParameter parameter) public IDeleteable<T> Where(string whereString, SugarParameter parameter)
{ {
if (DeleteBuilder.Parameters == null)
{
DeleteBuilder.Parameters = new List<SugarParameter>();
}
DeleteBuilder.Parameters.Add(parameter); DeleteBuilder.Parameters.Add(parameter);
return this; return this;
} }
public IDeleteable<T> Where(string whereString, SugarParameter[] parameters) public IDeleteable<T> Where(string whereString, SugarParameter[] parameters)
{ {
if (DeleteBuilder.Parameters == null)
{
DeleteBuilder.Parameters = new List<SugarParameter>();
}
DeleteBuilder.Parameters.AddRange(parameters); DeleteBuilder.Parameters.AddRange(parameters);
return this; return this;
} }
public IDeleteable<T> Where(string whereString, List<SugarParameter> parameters) public IDeleteable<T> Where(string whereString, List<SugarParameter> parameters)
{ {
if (DeleteBuilder.Parameters == null)
{
DeleteBuilder.Parameters = new List<SugarParameter>();
}
DeleteBuilder.Parameters.AddRange(parameters); DeleteBuilder.Parameters.AddRange(parameters);
return this; return this;
} }

View File

@@ -965,7 +965,12 @@ namespace SqlSugar
addParameters.Add(parameter); addParameters.Add(parameter);
} }
parsmeters.AddRange(addParameters); parsmeters.AddRange(addParameters);
itemSql = itemSql.TrimEnd(';')+";"; itemSql = itemSql
.TrimEnd('\r')
.TrimEnd('\n')
.TrimEnd('\r')
.TrimEnd('\n')
.TrimEnd(';')+";";
sqlBuilder.AppendLine(itemSql); sqlBuilder.AppendLine(itemSql);
index++; index++;
} }

View File

@@ -15,12 +15,12 @@ namespace SqlSugar
IDbFirst SettingNamespaceTemplate(Func<string, string> func); IDbFirst SettingNamespaceTemplate(Func<string, string> func);
RazorFirst UseRazorAnalysis(string razorClassString, string classNamespace = "Models"); RazorFirst UseRazorAnalysis(string razorClassString, string classNamespace = "Models");
IDbFirst IsCreateAttribute(bool isCreateAttribute = true); IDbFirst IsCreateAttribute(bool isCreateAttribute = true);
IDbFirst IsCreateDefaultValue(bool isCreateDefaultValue=true); IDbFirst IsCreateDefaultValue(bool isCreateDefaultValue = true);
IDbFirst Where(params string[] objectNames); IDbFirst Where(params string[] objectNames);
IDbFirst Where(Func<string,bool> func); IDbFirst Where(Func<string, bool> func);
IDbFirst WhereColumns(Func<string, bool> func); IDbFirst WhereColumns(Func<string, bool> func);
IDbFirst Where(DbObjectType dbObjectType); IDbFirst Where(DbObjectType dbObjectType);
void CreateClassFile(string directoryPath, string nameSpace = "Models"); void CreateClassFile(string directoryPath, string nameSpace = "Models");
Dictionary<string, string> ToClassStringList(string nameSpace = "Models"); Dictionary<string, string> ToClassStringList(string nameSpace = "Models");
void Init(); void Init();
} }

View File

@@ -10,6 +10,10 @@ namespace SqlSugar
{ {
int reval = 0; int reval = 0;
if (thisValue == null) return 0; if (thisValue == null) return 0;
if (thisValue is Enum)
{
return (int)thisValue;
}
if (thisValue != null && thisValue != DBNull.Value && int.TryParse(thisValue.ToString(), out reval)) if (thisValue != null && thisValue != DBNull.Value && int.TryParse(thisValue.ToString(), out reval))
{ {
return reval; return reval;
@@ -20,6 +24,10 @@ namespace SqlSugar
public static int ObjToInt(this object thisValue, int errorValue) public static int ObjToInt(this object thisValue, int errorValue)
{ {
int reval = 0; int reval = 0;
if (thisValue is Enum)
{
return (int)thisValue;
}
if (thisValue != null && thisValue != DBNull.Value && int.TryParse(thisValue.ToString(), out reval)) if (thisValue != null && thisValue != DBNull.Value && int.TryParse(thisValue.ToString(), out reval))
{ {
return reval; return reval;