ef 批量删除问题
[code=csharp]
public int DeleteAll(string strListIDs)
{
using (csh0067Entities db = new csh0067Entities())
{
SqlParameter[] pars = new SqlParameter[]{
new SqlParameter("@CodeID",SqlDbType.NVarChar,100)
};
pars[0].Value = strListIDs;
string strSql="delete from InviteCode where CodeID in( @CodeID)";
//string strSql = "delete from InviteCode where CodeID in( " + strListIDs + ")";
return db.ExecuteStoreCommand(strSql, pars);
}
}
[/code
上面的代码删除一条数据正常,删除多条数据就报错了,是我写的语法有问题吗
如果我把最后2行代码修改成下面代码,也就正确了
string strSql = "delete from InviteCode where CodeID in( " + strListIDs + ")";
return db.ExecuteStoreCommand(strSql, null);
请问一下,我第一种写法错在哪里,谢谢
------解决方案-------------------- public int DeleteAll(string strListIDs)
{
using (csh0067Entities db = new csh0067Entities())
{
var pars = new DbParameter[]{