Answer the question
In order to leave comments, you need to log in
ASP.NET Core and floating point in EFCore. How to implement?
Good day gentlemen. Tell. I'm suffering for a while. Is it not possible to enter values with a dot into the database through web forms? It seems like a float is a floating point value, but I can only enter a semicolon into the base. SQL Server base. The fields in the model are float. Tried double, same thing. in basis in properties of the table I see that float is specified. The model also seems to be in order. But every time when I try to score through the value form with a dot, I swear that the data is not valid for the field.
var cultureInfo = new CultureInfo("ru-RU");
cultureInfo.NumberFormat.NumberDecimalSeparator = ".";
System.Threading.Thread.CurrentThread.CurrentUICulture = cultureInfo;
Answer the question
In order to leave comments, you need to log in
Alternatively, replace the dot with a comma.
Here you get a model for writing to the controller.
Fields, where we convert numbers into a string and do a replay.
public ActionResult Edit(string number)
{
number = number.ToString().Replace(".",",");
return View();
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question