这条语句怎么用linq 写
C# code
SELECT * FROM [News] as n1 inner join news_type as n2 on n1.news_type=n2.type_id
------解决方案--------------------
News 实体中有 news_type这个字段么?
如果没有:
NewsDataContext nc=new NewsDataContext
var list= (from x in nc.News join y in nc.news_type on x.news_type equals y.type_id select new {x,y});
也可以这样:
class temp
{
public int newsId{get;set;}
public string news_type{get;set;}
}
IList<temp> list= (from x in nc.News join y in nc.news_type on x.news_type equals y.type_id select new temp{newsId=x.newsId, news_type=y.news_type}).ToList<temp>;