Delete Join Sql Bug

This commit is contained in:
sunkaixuan 2017-06-22 17:29:53 +08:00
parent b0cdff77b5
commit 20deae1124
6 changed files with 24 additions and 12 deletions

View File

@ -26,7 +26,7 @@ namespace OrmTest
// new SelectQuery(1).Init();
// new AutoClose(1).Init();
// new Insert(1).Init();
// new Delete(1).Init();
new Delete(1).Init();
// new Update(1).Init();
// new Mapping(1).Init();
// new DataTest(1).Init();

View File

@ -51,6 +51,11 @@ namespace OrmTest
base.Check(@"DELETE FROM [STudent] WHERE ( [ID] = @Id0 ) ", new List<SugarParameter>() {
new SugarParameter("@Id0",1)
}, 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()

View File

@ -109,12 +109,15 @@ namespace SqlSugar
return this;
}
public IDeleteable<T> Where(string whereString, object whereObj = null)
public IDeleteable<T> Where(string whereString, object parameters = null)
{
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;
}

View File

@ -18,7 +18,7 @@ namespace SqlSugar
IDeleteable<T> In<PkType>(PkType primaryKeyValue);
IDeleteable<T> In<PkType>(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();
}
}

View File

@ -109,12 +109,16 @@ namespace SqlSugar
return this;
}
public IDeleteable<T> Where(string whereString, object whereObj = null)
public IDeleteable<T> Where(string whereString, object parameters = null)
{
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;
}

View File

@ -18,7 +18,7 @@ namespace SqlSugar
IDeleteable<T> In<PkType>(PkType primaryKeyValue);
IDeleteable<T> In<PkType>(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();
}
}