如何将所有记录删除使用亚音速3表 [英] How to delete all records in a table using SubSonic 3
本文介绍了如何将所有记录删除使用亚音速3表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想从表中使用这种方法的所有记录删除:
I'm trying to delete all the records from a table using this approach:
new Delete<Contact>().Execute();
该语句线路出现故障与的NullReferenceException
在 BuildDeleteStatement
方法:
This statement fails with a NullReferenceException
in BuildDeleteStatement
method at line:
sb.Append(query.FromTables[0].QualifiedName);
由于,虽然FromTables有一个入口,它被设置为null。我也试过,但它并没有工作之一:
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?
推荐答案
您可以用回购DeleteMany方法做到这一点:
You can do this with the repo DeleteMany method:
SubSonicRepository<Contact> repo = new SubSonicRepository<Contact>(new YourDB());
repo.DeleteMany(contact => true);
我正在使用的拉姆达只是为了确保所有的记录都被选中。
The lambda I'm using is just to ensure all records are selected.
这篇关于如何将所有记录删除使用亚音速3表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文