当我试图在实体框架上保存一个int值时,我得到了以下错误 -
System.OverflowException:'值太大或太小 一个Int32。'
注意该值类似于 - 9093739202727
有没有更好的方法来处理这个值?
代码:
if (result.responseCode.ToString() == "APPROVED")
{
var sub = new Subscriptions();
sub.UserEmail = result.merchantOrderId;
sub.SaleNumber = Int32.Parse(result.orderNumber.ToString());
sub.LastTransectionId = Int32.Parse(result.transactionId.ToString());
sub.LastUpdatedTime = DateTime.Now;
if (twoCheckout.ProductTypeId == "m")
{
sub.ExpirationDate = DateTime.Today.AddMonths(1);
}else if (twoCheckout.ProductTypeId == "y")
{
sub.ExpirationDate = DateTime.Today.AddYears(1);
}
sub.Status = false;
db.Subscriptions.Add(sub);
db.SaveChanges();
}
答案 0 :(得分:0)
C#的task_limit
范围是-2,147,483,648到2,147,483,647。您需要int
或更好的long
来处理大的值。
https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/int