我在sql中遇到问题, 假设我有一个主表“项目”,它的项目包括2个不同的细节,如项目成员,项目文件。 现在的情况是,项目可能包含10个成员和4个文件,即对应一个项目ID。
我如何从三个表中获取数据并在UI中显示。
var qry = (from p in dbModel.tbl_PROJECT
join q in dbModel.tbl_PROJECTxFILE
on p.ProjectID equals q.ProjectID
into list2
from l2 in list2.DefaultIfEmpty()
join f in dbModel.tbl_FILE
on l2.FileID equals f.FileID
into list3
from l3 in list3.DefaultIfEmpty()
join c in dbModel.tbl_PROJECTxCOMPONENT
on p.ProjectID equals c.ProjectID
into list8
from l8 in list8.DefaultIfEmpty()
join a in dbModel.tbl_PROJECTCOMPONENT
on l8.ProjectComponentID equals a.ProjectComponentID
into list9
from l9 in list9.DefaultIfEmpty()
where p.ProjectID == projectId
select new ProjectDetails1
{
ProjectTtile = p.ProjectTtile,
ProjectIcon = p.ProjectIcon,
ProjectDescription = p.ProjectDescription,
ExpectedDeadline = p.ExpectedDeadline,
FileName = l3.FileName,
FilePath = l3.FilePath,
FileSize = l3.FileSize,
UploadDate = l3.UploadDate,
FileID = l3.FileID,
Title = l9.Title,
ColorId = l9.ColorID,
ProjectComponentID=l9.ProjectComponentID,
}).ToList();
答案 0 :(得分:0)
您是否尝试过滤特定行?然后你需要使用Offset和Fetch子句,例如....你首先指定OFFSET子句,指示你想要跳过多少行(如果你不想跳过任何行,则为0);然后,您可以选择指定FETCH子句,指示要过滤的行数,希望这会有所帮助。谢谢