如何从两个表mvc3 EF获取数据 [英] how to get data from two tables mvc3 EF
本文介绍了如何从两个表mvc3 EF获取数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
第一张桌子
First table
Myid
Uid
Start_Date
Last_login
Lastwall_send
Lastmatch_found
Score
Name
秒表
second Table
Myid
Uid
Fid
Subject
Message
Star_Date
Read_message
Read_Dat
i想要从firsttable使用我想要的所有消息fid在第一张表中是uid
简而言之我希望所有来自用户的消息表(第二个)的消息他朋友的名字和名字存放在第1表
i want to all the message i want name from firsttable using fid whhich is uid in 1st table
in short i want to all the message from message table(2nd) of a user with the name of his friend and name is stored in 1st table
推荐答案
你需要在这里使用加盟操作
喜欢:
var messages =(来自Context.FirstTable中的tab1
上下文中的
加入tab2.SecondTable
tab1.Primarykey上的
等于tab2.Foreign键
select tab2.Message).ToLis t();
尝试这样。
请回复您的查询。
谢谢
:)
You need to use join operation here
like :
var messages = (from tab1 in Context.FirstTable
join tab2 in Context.SecondTable
on tab1.Primarykey equals tab2.Foreign key
select tab2.Message).ToList();
try like this.
Please post back your queries if any.
Thanks
:)
这篇关于如何从两个表mvc3 EF获取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文