Linq To SQL Without Explicit Foreign Key Relationships

前端 未结 7 1504
陌清茗
陌清茗 2020-12-16 14:54

I am working with a few legacy tables that have relationships, but those relationships haven\'t been explicitly set as primary/foreign keys. I created a .dbml file using \"

7条回答
  •  隐瞒了意图╮
    2020-12-16 15:37

    Is the association set to One to One or One to Many? If you have the association set to One to Many, then what you have is an EntitySet, not an EntityRef and you'll need to use a where clause on the dependent set to get the correct value. I suspect that you want a One to One relationship, which is not the default. Try changing it to One to One and see if you can construct the query.

    Note: I'm just guessing because you haven't actually told us what the "trouble" actually is.

提交回复
热议问题