从3个表中检索数据到单个网格视图 [英] retrieve data from 3 tables into single grid view

查看:119
本文介绍了从3个表中检索数据到单个网格视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



i初学者在实体框架中

i有存储过程,根据它们之间的关系从3个表中选择数据



通常当我需要从一个表中检索数据时我转到添加功能导入,选择返回类型:实体然后选择表名,然后显示数据。

当我需要检索标量值时我选择返回类型:Scalar



还有一个名为complex的选项,我应该选择它????

以及如何从一个GridView中获取3个表中的所有数据



注意:当我运行存储过程时sql server,它运行正常。

i需要在网格视图中获取这些数据

hi ,
i am beginner in Entity framework
i have stored procedure that select data from 3 tables based on relation between them

usually when i need to retrieve data from one table i go to Add function import , choose return type : Entities and then choose table name , then the data will be displayed .
and when i need to retrieve a scalar value i choose return type :Scalar

there is one more option called complex , should i choose it ???
and how to get the all data from 3 table in one GridView

note : when i run the stored procedure is sql server , it works fine .
i need to get these data in a grid view

推荐答案

即使你必须为函数导入存储过程也是如此,并创建一个新的复杂类型来获取所需的数据。请浏览我写的博客文章,了解实现您想要的步骤: -



在实体框架模型第一种方法中使用存储过程(第一部分 - 添加新的存储过程) [ ^ ]







http://microsofttechnologiesmaster.blogspot.in/2014/04/using-stored-procedures-in-entity.html?m=1



希望这对您有帮助。
Even you have to do function import for the stored procedure as well and create a new complex type to get the desired data. Please go through this blog post written by me for steps to achieve what you want :-

Using stored procedures in Entity Framework Model First Approach (Part I - Adding New Stored procedure)[^]

OR

http://microsofttechnologiesmaster.blogspot.in/2014/04/using-stored-procedures-in-entity.html?m=1

Hope this will definitely of help to you.


Hai你应该选择复杂类型为什么因为返回类型是表格,



或Else



Hai u should select Complex type why because return type is Table ,

or Else

var Query = from Wi in objShortcutDAO.Table1
                        join Wt in objSettings.Table2 on Wi.WorkTypeID equals Wt.WorkTypeID
                        join t in objSettings.Table3  on Wi.TradeID equals t.TradeID
                        join u in objSettings.Table4 on Wi.UnitID equals u.UnitID
                        where Wi.WorkOrderItemID == Convert.ToInt32(e.Value)

                        select new
                        {
                      Name = t.TradeName + "," + u.UnitName + "," +       Wt.WorkTypeName,                
                      Id = t.TradeID + "," + Wt.WorkTypeID + "," + u.UnitID

                        };


这篇关于从3个表中检索数据到单个网格视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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