数据集中的关系表始终返回 0 行

发布于 2024-09-10 14:09:43 字数 1311 浏览 5 评论 0原文

我在 VS 2005 数据集设计器中创建了一个强类型数据集。 有两个表以一对多关系相互关联:Claim 和 ClaimDetail。设计器自动创建一个函数 GetClaimDetailRows,它返回 ClaimRow 的所有 ClaimDetailRows。 为什么这个数组的长度总是0? 因为 ClaimDetail 包含超过 4000 万行,所以在调用 GetClaimDetailRows 之前我没有填充它,而是配置了它的 select 命令,它需要一个参数 idData 来仅填充相关记录。但这似乎不起作用,因为 ClaimDetail-Datatable 是空的。

替代文本
(来源:bilder-hochladen.net) 。

ClaimRow-Class 中自动生成的函数返回所有相关的 ClaimDetailRows:

        Public Function GetClaimDetailRows() As ClaimDetailRow()
            If (Me.Table.ChildRelations("Claim_ClaimDetail") Is Nothing) Then
                Return New ClaimDetailRow(-1) {}
            Else
                Return CType(MyBase.GetChildRows(Me.Table.ChildRelations("Claim_ClaimDetail")),ClaimDetailRow())
            End If
        End Function

调试时我发现它跳转到 else 块但返回 0 行 我是否必须先为每个索赔填写索赔详细信息数据表(ClearBeforeFill=True)?但后来我不需要再使用这个功能了。

更新:我现在在调用子函数之前填充数据表(ClearBeforeFill=True)并且它可以工作。但我不明白为什么当我尝试访问子关系而不填充该数据表(至少有 0 行)时它不能抛出异常(可选)。相反,它返回 0 行,这些行可能是正确的,也可能是错误的,并且很难检测到。这是缺乏设计还是我错过了什么?

I have created a strongly typed dataset in the VS 2005 Dataset Designer.
There are two tables that relates to each other in a one to many relationship: Claim and ClaimDetail. The designer automatically creates a function GetClaimDetailRows which returns all ClaimDetailRows for a ClaimRow. Why is this Array's length always 0?
Because ClaimDetail contains more than 40 Million rows, i did'nt fill it before i call GetClaimDetailRows but had configured it's selectcommand that it takes a parameter idData to fill only the related records. But that seems not to work because the ClaimDetail-Datatable is empty.

alt text
(source: bilder-hochladen.net)

The automaticaly generated function in the ClaimRow-Class which returns all related ClaimDetailRows:

        Public Function GetClaimDetailRows() As ClaimDetailRow()
            If (Me.Table.ChildRelations("Claim_ClaimDetail") Is Nothing) Then
                Return New ClaimDetailRow(-1) {}
            Else
                Return CType(MyBase.GetChildRows(Me.Table.ChildRelations("Claim_ClaimDetail")),ClaimDetailRow())
            End If
        End Function

When debugging i see that it jumps into the else block but returns 0 rows.
Do i have to fill the Claimdetail-Datatable first(ClearBeforeFill=True) for each Claim? But then i dont need to use this function anymore.

UPDATE: I now fill the Datatable(ClearBeforeFill=True)before i call the Child-function and it works. But i dont understand why it could not throw an exception(optionally) when i try to acess a child-relation without having that datatable being filled(at least with 0 rows). Instead of that it returns 0 rows what can be correct or incorrect and is difficult to detect. Is this a lack of design or am i missing something?

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

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

发布评论

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

评论(1

牵你手 2024-09-17 14:09:43

因为生成的 GetChildRows() 假定(所有)子记录都已加载到内存中。

您必须在客户端部分(表单)编写一些代码。您可以使用 BindingSource.CurrentChanged 并将适当的记录填充到子表中。

Because the generated GetChildRows() assumes (all) the child records are loaded into memory.

You'll have to write some code in the client part (Form). You can use the BindingSource.CurrentChanged and fill the appropriate records into the child table.

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