开发者

LINQ weak relation between tables

开发者 https://www.devze.com 2022-12-25 15:17 出处:网络
I have two tables with a weak relation. I need get a text value from one table using a key from another.

I have two tables with a weak relation. I need get a text value from one table using a key from another. I am using the following C# LINQ code:

City = rea.tRealEstateContact.tPostnumre != null ? rea.tRealEstateContact.tPostnumre.Bynavn : string.Empty

But when the key cannot be found 开发者_运维技巧in the table 1(tPostnumre), an exception is thrown.

How should I do this?


Isn't there a tPostnumreID in the RealEstateContact table that's used to link to tPostnumre?

 City = rea.tRealEstateContact.tPostnumreID != null ?
          rea.tRealEstateContact.tPostnumre.Bynavn : string.Empty 
0

精彩评论

暂无评论...
验证码 换一张
取 消