首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

这条语句如何用linq 写

2012-01-09 
这条语句怎么用linq 写C# codeSELECT * FROM [News] as n1 inner join news_type as n2 on n1.news_typen

这条语句怎么用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>;

热点排行