Click here to Skip to main content
15,892,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to write a linq to sql query for the below sql query.
SQL
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
Posted
Updated 23-Feb-11 3:06am
v2

1 solution

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.
 
Share this answer
 
Comments
Member 7698913 23-Feb-11 12:42pm    
but it will only show language name how country name will come?
TheyCallMeMrJames 23-Feb-11 14:19pm    
change c.lkpGeoLanguage.languageName to string.Format("{0} {1}", c.countryName, c.lkpGeoLanguage.languageName) and that should do the trick. Cheers.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900