在 asp.net mvc 中使用 Linq-to-sql 进行 Innerjoin?
我使用 asp.net mvc...如何在 linq-to-sql 中为此 sql 查询编写内部联接
select M.Mat_id,M.Mat_Name,T.Name as Measurement,M.Mat_Type as Description
from Material as M inner join MeasurementTypes as T
on M.MeasurementTypeId = T.Id where M.Is_Deleted=0
我的存储库类有这个,
public class ConstructionRepository
{
private CRDataContext db = new CRDataContext();
public IQueryable<Material> FindAllMaterials()
{
return db.Materials;
}
}
我的结果 db.Materials 是表数据..我不想与另一个表内连接并显示数据....
public class ConstructionRepository
{
private CRDataContext db = new CRDataContext();
public IQueryable<Material> FindAllMaterials()
{
//inner join query
}
}
任何建议...
I use asp.net mvc... How to write an inner join in linq-to-sql for this sql query
select M.Mat_id,M.Mat_Name,T.Name as Measurement,M.Mat_Type as Description
from Material as M inner join MeasurementTypes as T
on M.MeasurementTypeId = T.Id where M.Is_Deleted=0
And my repository class has this,
public class ConstructionRepository
{
private CRDataContext db = new CRDataContext();
public IQueryable<Material> FindAllMaterials()
{
return db.Materials;
}
}
My result db.Materials
is the table data.. I dont want that i want to innerjoin with another table and show the data....
public class ConstructionRepository
{
private CRDataContext db = new CRDataContext();
public IQueryable<Material> FindAllMaterials()
{
//inner join query
}
}
Any suggestions...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这将返回带有您在 SQL 查询中指定的详细信息的匿名类型,但您可能更愿意简单地返回材质对象本身。
This will return anonymous types with the details you've specified in your SQL query but you may prefer to simply return the material objects themselves.