如何从多个表中获取数据 [英] How to get data from multiple tables

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

问题描述

你好朋友



i在mvc3中有一个小问题



我正在使用asp.net的实体框架mvc3



i有两张表与外键关系船



在我的视图中我想显示来自两者的数据表格和视图绑定到一个模型





plz建议我....

Hi freinds

i have small question in mvc3

am using Entity framework with asp.net mvc3

i have two tables with foreignkey relation ship

in my view i want to display data from both the tables and view is binded to one model


plz suggest me....

推荐答案

您应该创建一个包含两个表信息的视图模型。基本上,您将创建一个类,您也将映射2个表数据实体。然后将View绑定到新视图模型,您将能够显示两个表中的信息。如果你想要一个例子,我需要看一些你已经拥有的代码。
You should make a view model that will contain information from both tables. Basically you will create a class that you will map the 2 table data entities too. Then bind the View to the new view model and you will be able to display information from both tables. If you want an example I will need to see some of the code you have already.


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

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