Display a decimal field as an int in Razor
asp.net-mvc-4, c#, razor, visual-studio-2010
Solution
Simply cast to an `int` on the page:
@((int)myDecimal)
You could of course also cast them beforehand. At any rate, casting will truncate any decimal places. If you need to round them then you should use `Math.Round()`.
Problem
i used entity framework to get a model from my oracle database and then ADO dbcontext generator to create my classes, the problem is that the "number" fields in oracle were passed as "decimal", what i want to do is to show them in my tables like integers. for example i have a cshtml view with a table, and it shows number_of_prod 123.00 i want it to show it like this: ``` number_of_prod 123 ``` maybe with [DisplayFormat .....] , but i dont know how to use it XD!.. thanks!