title: How to return only the integer part of a decimal value from a SQL Server database?
body: <p>I need to return only the integer part of a number I received through an http request from a SQL Server view.</p>
  <p>For example, if a number inside a database is 1234, I need to receive the value 1234, but the ASP.NET framework returns 1234.0.</p>
  <p>The zero after the decimal point is my problem.</p>
  <p>Despite my column being in decimal format, all saved values ​​are integers. I can't change the column datatype of this view.</p>
  <p>My view is composed only by two columns:</p>
  <pre><code>PERSON_CODE (decimal(6,0), null)
  PERSON_NAME (varchar(115), null)
  </code></pre>
  <p>I've already tried to format using <code>[DisplayFormat(...</code>, but it makes no difference, my returned value always has the 0 after the decimal point.</p>
  <pre><code>public class VW_PERSONS
  {
      [Key]
      [DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = &quot;{0:0}&quot;)]
      public decimal PERSON_CODE { get; set; }
  
      public string PERSON_NAME { get; set; }
  }
  </code></pre>
  <p>My controller:</p>
  <pre><code>[HttpGet]
  public object GetPersonByCode(decimal PERSON_CODE)
  {
      try
      {
          return new Business.Person().GetPersonByCode(PERSON_CODE);
      }
      catch (Exception ex)
      {
          throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, Util.GetExceptionMessages(ex)));
      }
  }
  </code></pre>
  <p>Inside my business:</p>
  <pre><code>internal PersonModel GetPersonByCode(string PERSON_CODE)
  {
      using (ExtranetEntities extranet = new ExtranetEntities())
      {
          int CODE_PERSON = int.Parse(PERSON_CODE);
  
          return new ContatoModel(extranet.VW_PERSONS.FirstOrDefault(r =&gt; r.PERSON_CODE == CODE_PERSON));
      }
  }
  </code></pre>
  <p>Can anyone help me solve this problem?</p>