I need to round FinalPrice the following ways based on an identifier:
- 0 = Not at all
- 1 = Up to the next Dollar
- 2 = Up to the next Half-dollar
Example of the expected rounding:
- ID 0: 133.15 => 133.15
- ID 1: 133.15 => 134.00
- ID 2: 133.15 => 133.50
public IQueryable<MyObj> GetPrices()
{
int roundingId = 0; //0 = no rounding. 1 = dollar rounding. 2 = half-dollar rounding.
var prices = from ps in ObjectContext.Products
select new MyObj
{
FinalPrice = (ps.IsCustomPrice ? ps.CustomPrice : ps.Retail),
}
return prices;
}
I wish I could use a custom function to do this rounding in LINQ to Entities...