代码之家  ›  专栏  ›  技术社区  ›  Yogesh

如何使用亚音速3删除表中的所有记录

  •  1
  • Yogesh  · 技术社区  · 15 年前

    我尝试使用以下方法从表中删除所有记录:

    new Delete<Contact>().Execute();
    

    这句话有一个错误 NullReferenceException BuildDeleteStatement 第行的方法:

    sb.Append(query.FromTables[0].QualifiedName);
    

    因为,尽管FromTables有一个条目,但它被设置为null。我也试过了,但也不起作用:

    var provider = ProviderFactory.GetProvider("MonitorData");
    new Delete<Contact>(provider).Execute();
    

    我做错了什么?

    1 回复  |  直到 10 年前
        1
  •  2
  •   Sam Chad    10 年前

    您可以使用repo DeleteMany方法执行此操作:

    SubSonicRepository<Contact> repo = new SubSonicRepository<Contact>(new YourDB());
    repo.DeleteMany(contact => true);