如何使用 SubSonic 3 删除表中的所有记录
我正在尝试使用这种方法删除表中的所有记录:
new Delete<Contact>().Execute();
此语句失败,并在 BuildDeleteStatement
方法中出现 NullReferenceException
行:
sb.Append(query.FromTables[0].QualifiedName);
因为,虽然 FromTables 有一个条目,它被设置为空。我也尝试过这个,但它也不起作用:
var provider = ProviderFactory.GetProvider("MonitorData");
new Delete<Contact>(provider).Execute();
我做错了什么?
I'm trying to delete all the records from a table using this approach:
new Delete<Contact>().Execute();
This statement fails with a NullReferenceException
in BuildDeleteStatement
method at line:
sb.Append(query.FromTables[0].QualifiedName);
Because, although FromTables has one entry, it is set to null. I also tried this but it doesn't worked either:
var provider = ProviderFactory.GetProvider("MonitorData");
new Delete<Contact>(provider).Execute();
What am I doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 repo DeleteMany 方法来执行此操作:
我使用的 lambda 只是为了确保选择所有记录。
You can do this with the repo DeleteMany method:
The lambda I'm using is just to ensure all records are selected.