专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > LINQ

这条语句如何用linq 写

发布时间:2011-06-24 21:52:53 文章来源:www.iduyao.cn 采编人员:星星草
这条语句怎么用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>;
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: