petapoco 中的一对多关系

发布于 2025-01-06 17:44:55 字数 554 浏览 3 评论 0原文

我有三个表

Company、CompanyLevel、CompanyType

Company 与 CompanyLevel 和 CompanyType 具有一对多关系

我使用以下查询来获取 Company 和 CompanyLevel

db.FetchOneToMany<Company, CompanyLevel>(x => x.CompanyId,
                           Sql.Builder.Append("SELECT CS.*, CL.* FROM Company AS CS").Append(
                        "LEFT OUTER JOIN [CompanyLevel] AS CL ON CS.CompanyId = CL.CompanyId")

其中 db 是 petapoco 的数据库实例。

是否可以在此查询中包含另一个关系(CompanyType),或者我们如何在查询中包含多个一对多关系。

我正在使用 Petapoco 扩展关系类。

I have three tables

Company, CompanyLevel, CompanyType

Company is having one to many relationship with CompanyLevel and CompanyType

I used following query to get Company and CompanyLevel

db.FetchOneToMany<Company, CompanyLevel>(x => x.CompanyId,
                           Sql.Builder.Append("SELECT CS.*, CL.* FROM Company AS CS").Append(
                        "LEFT OUTER JOIN [CompanyLevel] AS CL ON CS.CompanyId = CL.CompanyId")

Where db is a database instance of petapoco.

Is it possible to include one more relationship (CompanyType) in this query or how we can include multiple one to many relationship in queries.

I am using Petapoco extension relationship class.

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

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

发布评论

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

评论(1

り繁华旳梦境 2025-01-13 17:44:55

您一次只能执行 1 个操作。如果您开始执行多个操作,那么您将返回比实际需要的更多结果。将查询拆分为多个查询可能会更好。

You can only do 1 onetomany at a time. If you start doing more than one, then you will be returning way to many results than is actually needed. Its probably then better to split up the query into multiple queries.

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