title: Data access using Entity Framework in ASP.NET MVC
body: <p>I have a table with these columns(type) as described below.</p>
  
  <p><strong>TABLE</strong></p>
  
  <pre><code>------------------------------------------------------------------
  Dir(str) | Twnshp(int) | Rng(int) | Section(int) | Xcell(int) | Ycell(int)
  ------------------------------------------------------------------
  </code></pre>
  
  <p>I am trying to do this query using EF. </p>
  
  <pre><code>SELECT Xcell,Ycell  FROM [CIR].[dbo].[TRS2Cell] where Twnshp = 1 and Rng = 4 and Section =31
  </code></pre>
  
  <p>After some study, I created a DAL Context and class as below.</p>
  
  <p><strong>PlotXYContext.cs</strong></p>
  
  <pre><code>public class PlotXYContext :DbContext
  {
      public DbSet&lt;PlotXY&gt; XYCells { get; set; }
  }
  </code></pre>
  
  <p><strong>PlotXY.cs</strong></p>
  
  <pre><code>[Table("TRS2Cell")]
  public class PlotXY
  {
  
      public string Dir { get; set; }
      [Key]
      public int Twnshp { get; set; }
      public int Rng { get; set; }
      public int Section { get; set; }
      public int Xcell { get; set; }
      public int Ycell { get; set; }
  }
  </code></pre>
  
  <p>Here is the code in my controller where I pass the three parameters. </p>
  
  <pre><code>PlotXYContext plotXYContext = new PlotXYContext();
          var query = from TRS2Cell in plotXYContext.XYCells
                      where TRS2Cell.Twnshp == 1
                      &amp;&amp; TRS2Cell.Rng == 4
                      &amp;&amp; TRS2Cell.Section == 31
                      select TRS2Cell.Xcell;
  </code></pre>
  
  <p>I need help with EF as I am new to it and also is this the right query?
  If so how do I retrieve the Xcell and Ycell values from the query.
  Also the table has no unique column, no nulls, nothing needs to be updated here. All I want is to do a select.</p>