I'm just starting out with the Entity Framework and ADO.NET Data Services and I've run into an issue that I can't seem to figure out. I have two tables, one that has user information and the other that has a created by field. Within the database, there isn't a foreign key between these tables. The user table contains an arbitrary Id, a username, and a display name. The created by field contains the user's username. In my entity I would like to have the user's display name since this is what I need to display and expose over the ADO.NET Data Service? I'm aware that I could restructure the database, but I was hoping that I could do the join using the username as I would in a SQL statement.
我刚刚开始使用实体框架和ADO.NET数据服务,我遇到了一个我似乎无法弄清楚的问题。我有两个表,一个有用户信息,另一个有字段创建。在数据库中,这些表之间没有外键。用户表包含任意Id,用户名和显示名称。创建的字段包含用户的用户名。在我的实体中,我想拥有用户的显示名称,因为这是我需要通过ADO.NET数据服务显示和公开的内容?我知道我可以重组数据库,但我希望我可以像在SQL语句中那样使用用户名进行连接。
Thanks in advance,
提前致谢,
-Damien
1 个解决方案
#1
You can make a view using a join of both tables, and then use this object to display the user's name.
您可以使用两个表的连接创建视图,然后使用此对象显示用户的名称。
There's some info on mapping custom queries here.
这里有关于映射自定义查询的一些信息。
#1
You can make a view using a join of both tables, and then use this object to display the user's name.
您可以使用两个表的连接创建视图,然后使用此对象显示用户的名称。
There's some info on mapping custom queries here.
这里有关于映射自定义查询的一些信息。