mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-10-15 10:45:08 +08:00
Delete Join Sql Bug
This commit is contained in:
@@ -26,7 +26,7 @@ namespace OrmTest
|
|||||||
// new SelectQuery(1).Init();
|
// new SelectQuery(1).Init();
|
||||||
// new AutoClose(1).Init();
|
// new AutoClose(1).Init();
|
||||||
// new Insert(1).Init();
|
// new Insert(1).Init();
|
||||||
// new Delete(1).Init();
|
new Delete(1).Init();
|
||||||
// new Update(1).Init();
|
// new Update(1).Init();
|
||||||
// new Mapping(1).Init();
|
// new Mapping(1).Init();
|
||||||
// new DataTest(1).Init();
|
// new DataTest(1).Init();
|
||||||
|
@@ -51,6 +51,11 @@ namespace OrmTest
|
|||||||
base.Check(@"DELETE FROM [STudent] WHERE ( [ID] = @Id0 ) ", new List<SugarParameter>() {
|
base.Check(@"DELETE FROM [STudent] WHERE ( [ID] = @Id0 ) ", new List<SugarParameter>() {
|
||||||
new SugarParameter("@Id0",1)
|
new SugarParameter("@Id0",1)
|
||||||
}, t5.Key, t5.Value, "Delte t5 error");
|
}, t5.Key, t5.Value, "Delte t5 error");
|
||||||
|
|
||||||
|
var t6 = db.Deleteable<Student>().Where("id=@id",new { id=1}).ToSql();
|
||||||
|
base.Check(@"DELETE FROM [STudent] WHERE id=@id", new List<SugarParameter>() {
|
||||||
|
new SugarParameter("@id",1)
|
||||||
|
}, t6.Key, t6.Value, "Delte t6 error");
|
||||||
}
|
}
|
||||||
|
|
||||||
public SqlSugarClient GetInstance()
|
public SqlSugarClient GetInstance()
|
||||||
|
@@ -109,12 +109,15 @@ namespace SqlSugar
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IDeleteable<T> Where(string whereString, object whereObj = null)
|
public IDeleteable<T> Where(string whereString, object parameters = null)
|
||||||
{
|
{
|
||||||
DeleteBuilder.WhereInfos.Add(whereString);
|
DeleteBuilder.WhereInfos.Add(whereString);
|
||||||
if (whereObj != null)
|
if (parameters != null)
|
||||||
{
|
{
|
||||||
DeleteBuilder.Parameters.AddRange(Context.Ado.GetParameters(whereObj));
|
if (DeleteBuilder.Parameters == null) {
|
||||||
|
DeleteBuilder.Parameters = new List<SugarParameter>();
|
||||||
|
}
|
||||||
|
DeleteBuilder.Parameters.AddRange(Context.Ado.GetParameters(parameters));
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@@ -18,7 +18,7 @@ namespace SqlSugar
|
|||||||
IDeleteable<T> In<PkType>(PkType primaryKeyValue);
|
IDeleteable<T> In<PkType>(PkType primaryKeyValue);
|
||||||
IDeleteable<T> In<PkType>(PkType[] primaryKeyValues);
|
IDeleteable<T> In<PkType>(PkType[] primaryKeyValues);
|
||||||
IDeleteable<T> In<PkType>(List<PkType> primaryKeyValues);
|
IDeleteable<T> In<PkType>(List<PkType> primaryKeyValues);
|
||||||
IDeleteable<T> Where(string whereString,object whereObj=null);
|
IDeleteable<T> Where(string whereString,object parameters=null);
|
||||||
KeyValuePair<string, List<SugarParameter>> ToSql();
|
KeyValuePair<string, List<SugarParameter>> ToSql();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -26,7 +26,7 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
DeleteBuilder.EntityInfo = this.Context.EntityProvider.GetEntityInfo<T>();
|
DeleteBuilder.EntityInfo = this.Context.EntityProvider.GetEntityInfo<T>();
|
||||||
string sql = DeleteBuilder.ToSqlString();
|
string sql = DeleteBuilder.ToSqlString();
|
||||||
var paramters = DeleteBuilder.Parameters==null?null:DeleteBuilder.Parameters.ToArray();
|
var paramters = DeleteBuilder.Parameters == null ? null : DeleteBuilder.Parameters.ToArray();
|
||||||
RestoreMapping();
|
RestoreMapping();
|
||||||
return Db.ExecuteCommand(sql, paramters);
|
return Db.ExecuteCommand(sql, paramters);
|
||||||
}
|
}
|
||||||
@@ -63,7 +63,7 @@ namespace SqlSugar
|
|||||||
primaryKeyValues.Add(value);
|
primaryKeyValues.Add(value);
|
||||||
}
|
}
|
||||||
var inValueString = primaryKeyValues.ToArray().ToJoinSqlInVals();
|
var inValueString = primaryKeyValues.ToArray().ToJoinSqlInVals();
|
||||||
Where(string.Format(DeleteBuilder.WhereInTemplate,SqlBuilder.GetTranslationColumnName(primaryFields.Single()), inValueString));
|
Where(string.Format(DeleteBuilder.WhereInTemplate, SqlBuilder.GetTranslationColumnName(primaryFields.Single()), inValueString));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -109,12 +109,16 @@ namespace SqlSugar
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IDeleteable<T> Where(string whereString, object whereObj = null)
|
public IDeleteable<T> Where(string whereString, object parameters = null)
|
||||||
{
|
{
|
||||||
DeleteBuilder.WhereInfos.Add(whereString);
|
DeleteBuilder.WhereInfos.Add(whereString);
|
||||||
if (whereObj != null)
|
if (parameters != null)
|
||||||
{
|
{
|
||||||
DeleteBuilder.Parameters.AddRange(Context.Ado.GetParameters(whereObj));
|
if (DeleteBuilder.Parameters == null)
|
||||||
|
{
|
||||||
|
DeleteBuilder.Parameters = new List<SugarParameter>();
|
||||||
|
}
|
||||||
|
DeleteBuilder.Parameters.AddRange(Context.Ado.GetParameters(parameters));
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@@ -140,7 +144,7 @@ namespace SqlSugar
|
|||||||
string primaryField = null;
|
string primaryField = null;
|
||||||
primaryField = GetPrimaryKeys().FirstOrDefault();
|
primaryField = GetPrimaryKeys().FirstOrDefault();
|
||||||
Check.ArgumentNullException(primaryField, "Table " + tableName + " with no primarykey");
|
Check.ArgumentNullException(primaryField, "Table " + tableName + " with no primarykey");
|
||||||
Where(string.Format(DeleteBuilder.WhereInTemplate,SqlBuilder.GetTranslationColumnName(primaryField), primaryKeyValues.ToJoinSqlInVals()));
|
Where(string.Format(DeleteBuilder.WhereInTemplate, SqlBuilder.GetTranslationColumnName(primaryField), primaryKeyValues.ToJoinSqlInVals()));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -18,7 +18,7 @@ namespace SqlSugar
|
|||||||
IDeleteable<T> In<PkType>(PkType primaryKeyValue);
|
IDeleteable<T> In<PkType>(PkType primaryKeyValue);
|
||||||
IDeleteable<T> In<PkType>(PkType[] primaryKeyValues);
|
IDeleteable<T> In<PkType>(PkType[] primaryKeyValues);
|
||||||
IDeleteable<T> In<PkType>(List<PkType> primaryKeyValues);
|
IDeleteable<T> In<PkType>(List<PkType> primaryKeyValues);
|
||||||
IDeleteable<T> Where(string whereString,object whereObj=null);
|
IDeleteable<T> Where(string whereString, object parameters = null);
|
||||||
KeyValuePair<string, List<SugarParameter>> ToSql();
|
KeyValuePair<string, List<SugarParameter>> ToSql();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user