简体   繁体   English

ASP.NET Linq to sql多个外键到主键的不同表

[英]ASP.NET Linq to sql multiple foreign keys to primary key different table

I have a table called claims which has an id called currencyId of datatype INT . 我有一个名为claims的表,该表具有一个名为currencyId的数据类型INT的ID。

Then also a table called tblCurrency with primary ID of currencyId . 然后还有一个名为tblCurrency的表,其主ID为currencyId

And then had an association which was fine. 然后有一个很好的关联。 Then in Linq I could use 然后我可以在Linq中使用

    <%# ((claim)Container.DataItem).currency.value %>

But now I have to add another INT column to tblClaims called finalCurrencyID which I also want an association with to tblCurrency . 但是现在我必须向tblClaims添加另一个INT列,称为finalCurrencyID ,我也希望与tblCurrency关联。

Just wondering how I could achieve this, so at the moment ((claim)Container.DataItem).currency.value is linking up claim.currencyId to tblCurrency.currencyID and getting tblCurrency.value . 只是想知道我怎么能做到这一点,所以在此刻((claim)Container.DataItem).currency.value的衔接claim.currencyIdtblCurrency.currencyID并获得tblCurrency.value

But how could I make it more flexible so I can determine which currencyID from tblClaims to call? 但是如何使它更加灵活,以便可以确定要从tblClaims调用哪个currencyID

If I read the right, I think you are looking for this: 如果我没看错,我认为您正在寻找:

<%# ((claim)Container.DataItem).finalCurrency.value %>

Assuming, of course, that you've wired up claim to have a L2S FK to finalCurrency . 当然,假设您已经claim将L2S FK连接到finalCurrency

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ASP.NET Identity UserID主键是自定义表中的外键和主键 - ASP.NET Identity UserID primary key to be foreign key and primary key in your custom table 使用asp.net将主键表的单选按钮列表的值获取到另一个外键表 - fetch values of radiobutton list of primary key table to another foreign key table using asp.net 使用ASP.NET中的外键将数据插入SQL Server数据库时出错(找不到主键) - Error inserting data into SQL Server database with foreign key in ASP.NET (could not find primary key) 从主键asp.net C#获取SQL外键列值 - Get SQL Foreign key columns values from Primary Key asp.net c# 使用 ASP.NET 动态数据/LINQ to SQL,如何让两个表字段与同一个外键有关系? - Using ASP.NET Dynamic Data / LINQ to SQL, how do you have two table fields have a relationship to the same foreign key? 在ASP.NET中使用主键插入外键 - Inserting Foreign key using primary key in asp.net 在ASP.NET动态数据/ LINQ to SQL中启用主键字段的编辑 - Enabling editing of primary key field in ASP.NET Dynamic Data / LINQ to SQL 在ASP.NET Web表单中使用SQL Server在一个表中使用两个外键 - Two foreign keys in one table using SQL Server in asp.net webform ASP.NET/SQL-使用外键从多个表中检索数据 - Asp.net/SQL - Retrieving data from multiple tables using foreign keys 带有ASP.Net后端的Azure移动应用程序使用外键将数据发布到SQL Server表 - Azure Mobile App with ASP.Net backend posting data to a SQL Server table with a foreign key
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM