I am trying to convert decimal value to string.
My coding is this:
public ActionResult Search(string searchString)
{
product = product.Where(a => a.model.ToUpper().Contains(searchString.ToUpper())
|| a.Category.name.ToUpper().Contains(searchString.ToUpper())
|| SqlFunctions.StringConvert((decimal)a.displaySize).Contains(searchString));
return View(product.ToList());
}
When searchString value is ‘5’ instead of decimal value, it will be shown product list. However, if searchString value is ‘5.5’, it won’t display the product list.
I don’t know why really..
Could you help me?
Many thanks.
It would probably be easier to convert
searchStringto a decimal, try this:You may want to use
TryParseinstead to ensure typesafety, depending on wheresearchStringis coming from