【发布时间】:2010-12-10 11:55:07
【问题描述】:
ASP.NET 3.5 C#
我正在使用 Linq 加入两个表。
表名是 MapAssets 和 ExitPoint。
在数据库中,它们与“有关系”相关
我正在我的 BLL 中编写一个函数来返回连接的表
public List<ExitPoints> GetExitPointDetailsByProjectID(int iProjectID)
{
ctx = new CoreDBDataContext();
var exitPointDetails = from ma in ctx.MapAssets
join ep in ctx.ExitPoints
on ma.MapAssetID equals ep.MapAssetID
where ma.ProjectID == iProjectID
select new
{
//would like to have data from both tables here
ctx.MapAssets,
ctx.ExitPoints
};
return exitPointDetails.ToList();
}
这显然行不通。而且我根本不知道要返回什么。
我对返回的所有限制是能够绑定到网格视图。
这是正确的方法吗?否则正确的方法是什么?
【问题讨论】:
标签: c# asp.net linq linq-to-sql