使用 Fluent 查询工具进行亚音速删除

发布于 2024-10-10 08:21:32 字数 249 浏览 0 评论 0原文

在 subsonic 2 中我们可以这样做:

public static void DeleteTable(SubSonic.TableSchema.Table table)
{
     new Delete().From(table).Execute();
}

我们如何在 v3 中做同样的事情?我似乎只能找到有关使用泛型来定位数据库中特定表的文档...我希望能够将它与上面的参数一起使用。

谢谢

In subsonic 2 we could do this:

public static void DeleteTable(SubSonic.TableSchema.Table table)
{
     new Delete().From(table).Execute();
}

How can we do the same thing in v3? I can only seem to find documentation about using generics to target a specific table in the database...I want to be able to use it with a parameter as above.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

新雨望断虹 2024-10-17 08:21:32

我得到了它。这似乎可以解决问题:

public static void DeleteTable(DatabaseTable table)
{
     new Delete<object>(table, table.Provider).Execute();
}

I got it. This seems to do the trick:

public static void DeleteTable(DatabaseTable table)
{
     new Delete<object>(table, table.Provider).Execute();
}
︶ ̄淡然 2024-10-17 08:21:32

您以某种方式使用 SimpleRepository.DeleteMany 方法

var repo = new SimpleRepository("ConnectionString");
repo.DeleteMany<YourClass>(x => true);

,或者(阅读您的评论后)类似的方法

public static void DeleteTable(DatabaseTable table)
{
    new SubSonic.Query.Delete<object>(table, ProviderFactory.GetProvider());
}

使用通用类型“对象”是因为删除需要传递一个类型,如果我们使用表和提供程序创建它,则不会使用该类型。

You use the SimpleRepository.DeleteMany method somehow like this

var repo = new SimpleRepository("ConnectionString");
repo.DeleteMany<YourClass>(x => true);

Or (after reading your comment) something like that

public static void DeleteTable(DatabaseTable table)
{
    new SubSonic.Query.Delete<object>(table, ProviderFactory.GetProvider());
}

The generic type "object" is used because Delete wants a Type passed, which is not used in case we create it using a table and provider.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文