动态数据关联相关表值?
我已使用动态数据在 Visual Studio 2010 中创建了一个 LINQ-to-SQL 项目。在这个项目中我有两个表。一个称为phones_extension,另一个称为phones_ten。 phones_extension 中的列列表如下所示: id、分机、前缀、did_flag、len、ten_id、restriction_class_id、sfc_id、name_display、building_id、楼层、房间、phone_id、department_id 在phones_ten中它看起来像这样: ID、名称、PBXID 现在,我希望能够以某种方式实现它,以便存在一个关联(或继承?),这本质上使我能够进行像phones_extension.ten这样的查询,并且它给我phones_ten.name的结果。现在我必须获取phones_extension.ten_id,然后将其与phones_ten.id 进行匹配 - 我正在尝试让DBML 自动处理此翻译。 这可能吗?
I have create a LINQ-to-SQL project in Visual Studio 2010 using Dynamic Data. In this project I have two tables. One is called phones_extension and the other phones_ten. The list of columns in phones_extension looks like this:
id, extension, prefix, did_flag, len, ten_id, restriction_class_id, sfc_id, name_display, building_id, floor, room, phone_id, department_id
In phones_ten it looks like this:
id, name, pbxid
Now, I'd like to be able to somehow make it so that there is an association (or inheritance?) that essentially results in me being able to make a query like phones_extension.ten and it gives me the result of phones_ten.name. Right now I have to get phones_extension.ten_id and then match that against phones_ten.id - I'm trying to get the DBML to handle this translation automatically.
Is this possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的,Dave,您需要在数据库中设置一个关系,以便在 Linq to SQL 中工作,您可以只创建关系(L2S 中的关联),但无论如何每个表上都需要有一个主键以允许编辑。
OK Dave, you need to setup a relatioship in the DB for this to work in Linq to SQL you could just create the relatioship (association in L2S) but there will need to be a primary key on each table anyway to allows edits.