将Sql转换为linq到sql .......... [英] Convert Sql into linq to sql..........

查看:110
本文介绍了将Sql转换为linq到sql ..........的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何为下面的SQL查询编写linq to sql查询.

how to write a linq to sql query for the below sql query.

SELECT distinct lkpGeoCountry.countryName,lkpGeoLanguage.languageName
FROM   dbo.lkpxrfGeoCountryLanguageTactic
INNER JOIN lkpGeoCountry
ON dbo.lkpxrfGeoCountryLanguageTactic.countryID =lkpGeoCountry.countryID
INNER JOIN lkpGeoLanguage
ON lkpxrfGeoCountryLanguageTactic.languageID=lkpGeoLanguage.languageID

推荐答案

如果创建内部连接是隐式的适当的DBML.创建文件并添加选定的表.确保上面的每个联接都存在关系.您的代码将类似于以下内容:

Inner joins are implicit if you create a proper DBML. Create the file and add the selected tables. Make sure the relationships are there per your joins above. Your code will be similar to the following:

YourDataContext dc = new YourDataContext();
var languages = dc.lkpxrfGeoCountryLanguageTactics.lkpGeoCountries.Select(c=>c.lkpGeoLanguage.languageName).Distinct();




干杯.




Cheers.


这篇关于将Sql转换为linq到sql ..........的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆