如何在发票标题的详细信息视图中显示发票明细

时间:2022-08-26 22:48:42

I have two tables: invoice_header (PK: org_number, supplier_number, invoice_number) and invoice_line (PK: org_number, supplier_number, invoice_number, seq). My Index view displays records from invoice_header. I am trying to get the Details view to display the corresponding records from the invoice_line table.

我有两个表:invoice_header(PK:org_number,supplier_number,invoice_number)和invoice_line(PK:org_number,supplier_number,invoice_number,seq)。我的索引视图显示来自invoice_header的记录。我试图获取详细信息视图以显示invoice_line表中的相应记录。

I'm receiving the error: "The number of primary key values passed must match number of primary key values defined on the entity. Parameter name: keyValues"

我收到错误:“传递的主键值的数量必须与实体上定义的主键值的数量匹配。参数名称:keyValues”

The error is here: 如何在发票标题的详细信息视图中显示发票明细

错误在这里:

And here is the relevant section from the Index view: 如何在发票标题的详细信息视图中显示发票明细

这是索引视图中的相关部分:

I suspect I need to have something for the "seq" column which is part of the composite PK on invoice_line. I want to see all records that match on org_number, supplier_number and invoice_number, regardless of seq.

我怀疑我需要为“seq”列提供一些内容,它是invoice_line上复合PK的一部分。我希望看到所有与org_number,supplier_number和invoice_number匹配的记录,无论seq如何。

1 个解决方案

#1


0  

If you're using Entity Framework, which I suspect you are, then Find is the wrong method. Find is for searching by primary keys and that would require you to feed in the values of the composite key. In this case I believe the method you want is Where. That will allow you to search via values instead of finding by the key.

如果你正在使用我怀疑你的Entity Framework,那么Find是错误的方法。查找是按主键搜索,这需要您输入组合键的值。在这种情况下,我相信你想要的方法是哪里。这将允许您通过值搜索而不是通过键查找。

Keep in mind that Where will not hit the PK index and can have performance issues. You'll want to do some testing. You can check out the link below to see a comparison of query types for EF.

请记住,哪里不会达到PK索引并且可能会出现性能问题。你想做一些测试。您可以查看以下链接,查看EF的查询类型比较。

http://msdn.microsoft.com/en-us/data/jj573936.aspx

#1


0  

If you're using Entity Framework, which I suspect you are, then Find is the wrong method. Find is for searching by primary keys and that would require you to feed in the values of the composite key. In this case I believe the method you want is Where. That will allow you to search via values instead of finding by the key.

如果你正在使用我怀疑你的Entity Framework,那么Find是错误的方法。查找是按主键搜索,这需要您输入组合键的值。在这种情况下,我相信你想要的方法是哪里。这将允许您通过值搜索而不是通过键查找。

Keep in mind that Where will not hit the PK index and can have performance issues. You'll want to do some testing. You can check out the link below to see a comparison of query types for EF.

请记住,哪里不会达到PK索引并且可能会出现性能问题。你想做一些测试。您可以查看以下链接,查看EF的查询类型比较。

http://msdn.microsoft.com/en-us/data/jj573936.aspx