ADO.NET实体:从3个表中获取数据 [英] ADO.NET Entity : getting data from 3 tables

查看:134
本文介绍了ADO.NET实体:从3个表中获取数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下表结构:

Table: Plant
 PlantID: Primary Key
 PlantName: String

Table: Party
 PartyID: Primary Key
 PartyName: String
 PlantID: link to Plant table

Table: Customer
 PartyID: Primary Key, link to Party
 CustomerCode: String

我想有Customer实体对象以下字段:

I'd like to have Customer entity object with following fields:

 PartyID: Primary Key
 CustomerCode: String
 PartyName: String
 PlantName: String

我有麻烦PlantName场(这是从植物表带来 我接客户到党和党植物与关联 但是我无法连接到客户工厂与关联(因为它没有一个) 我无法厂表添加到映射,当我做到这一点 - 我收到以下错误:

I am having trouble with PlantName field (which is brought from Plant table I connected Customer to Party and Party to Plant with associations However I can not connect Customer to Plant with association ( because it does not have one) I can not add Plant table to mapping, when I do that - I am getting following error:

Error 3024: Problem in Mapping Fragment starting at line 352: Must specify mapping for all key properties (CustomerSet.PartyID) of the EntitySet CustomerSet

删除植物协会工作。 任何提示或指示非常AP preciated。

Removing Plant association works. Any hints or directions very appreciated.

推荐答案

您可以通过使用实体对象的参考路径得到这些领域。

You can get these fields by using the reference path on the Entity Object.

要获得PartyName,使用此语法: Customer.Party.PartyName

To get the PartyName, use this syntax: Customer.Party.PartyName

要获得PlantName,使用此语法: Customer.Party.Plant.PlantName

To get the PlantName, use this syntax: Customer.Party.Plant.PlantName

这篇关于ADO.NET实体:从3个表中获取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆