从3个表获取数据

从3个表获取数据

本文介绍了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

我想客户实体对象具有以下字段:

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 tableI connected Customer to Party and Party to Plant with associationsHowever 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

拆除工厂协会工程。
任何提示或方向非常感谢。

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个表获取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 01:58