实体框架从另一个表中的查找中获取实体字段。 [英] Entity Framework Get an entity field from a lookup in another table.
问题描述
我有一个实体客户端。
它有ClientID,Name,Address1,Arrdess2 City。在客户端表中,city是cities表中的ID,我需要返回城市名称
It has ClientID, Name, Address1, Arrdess2 City. In the client table city is an ID in the cities table and I need to return the city name
所以代码如下所示我需要从城市表中获取城市名称我这样做了吗?
so the code looks like this below I need to get the city name form the city table how do I do this?
谢谢!
Mike
public class Client
public class Client
{
public int ClientID {get; set;}
public int ClientID {get;set;}
public string Name {get; set;}
public string Name {get;set;}
public string Address1 {get; set;}
public string Address1 {get;set;}
public string Address2 {get; set ;}
public string Address2 {get;set;}
公共字符串City {get; set;}
public string City {get;set;}
}
推荐答案
你好Bulldog61,
Hi Bulldog61,
喜欢你的头衔提到,您的案例与EF更相关,我将帮助您将案件移至EF论坛以获得更好的支持。
Like your title mentioned, your case more related to EF, I will help move your case to EF forum for better support.
祝你好运,
Kristin
这篇关于实体框架从另一个表中的查找中获取实体字段。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!