Reputation: 1030
Trying to execute this code:
process.POPManagerPreparation.JudgementPercentage = (decimal?)txtAlternativePercentage.Value;
That works fine, but when the code Context.Current.SaveChanges();
is executed to save it in the database this ArgumentException occurs:
An error occurred while updating the entries. See the inner exception for details.
System.ArgumentException: Parameter value '3,0000' is out of range.
It's definitely about the field i've added, I know because of the value. (it changes when I check with other input)
I tried to change my computer settings from NL-nl to US-en, because it feels like there is something wrong with that but didn't solve it, the same error still exist.
Also tried some things on the text field, same error still:
<telerik:RadNumericTextBox MinValue="0" MaxLength="100" ID="txtAlternativePercentage"
runat="server" Type="Percent" Culture="en-US" Width="80px" LabelCssClass=""
Label="Verhogingspercentage:" LabelWidth="130" AutoPostBack="true"
OnTextChanged="SalaryChanged" Visible="false">
<NumberFormat DecimalDigits="1" />
<IncrementSettings InterceptArrowKeys="False" InterceptMouseWheel="False" />
</telerik:RadNumericTextBox>
To be complete, the database field is: decimal(10, 5)
so that's seems to be alright too. Found online a lot of issues with people that used too small fields but nothing on my issue.
Upvotes: 1
Views: 1398
Reputation: 1030
I solved it by changing to a float field like Pankaj Gupta suggested. This works fine.
so I've learned to not use a decimal unless you are sure that the value is strict about the decimal form it expects.
Upvotes: 0
Reputation: 14488
You can specify the precision of your properties in your modelBuilder:
modelBuilder.Entity<POPManagerPreparation>()
.Property(e => e.JudgementPercentage)
.HasPrecision(10,5);
Upvotes: 1