title: How to get the particular value of column using the primary key - entity framework?
body: <p>I have different tables.
  For example Table 1 contains the name of Persons
  Table 2 contains the Country name and Person Id</p>
  
  <pre><code>Table 1:
  PersonId     PersonName
  1            John
  2            Smith
  3            Kelly
  
  
  Table 2:
  LocationId   Continent      Country     PersonId
  1            Asia           Japan       1
  2            Asia           China       2
  
  // There is C# method where PersonId should be passed.. suppose id=2 is passed
  
  var person = await _repository.Person.FirstOrDefaultAsync(x =&gt; x.PersonId == id); //This find Smith from DB
  var location = await _repository.Location.FirstOrDefaultAsync(x =&gt; x.LocationId == person.PersonId);   
  // location variable will get all values of second row from Table 2 i.e LocationID=2, Continent=Asia, Country=China, PersonId=2
  // but i just need value of Country column i.e China of PersonId=2
  
  // Though I can get CountryName from this -- have to write below extra code for that
  var country = location.Country;   // this will get Country = China
  
  How can I achieve this in a single line?
  
  // something like
  var location = await _repository.Location.FirstOrDefaultAsync(x =&gt; x.LocationId == person.PersonId).Country();
  </code></pre>