我有一張表,其中包含一個名爲Days1的定義字段decimal(5,2)
此表映射到edmx文件中,並且有一個將值插入此表的過程。使用實體框架對十進制數進行縮放
每當我試着用我的代碼
x.Days1 = 7.5;
我得到以下錯誤插入值7.5:
如果我沒有錯誤發生相同的值執行該過程。 如果我把價值7.51我的代碼:
x.Days1 = 7.51
出現任何錯誤。我認爲問題出在點之後的數字。我有值7.5〜我怎麼可以把它作爲7.50
存儲過程是什麼:
ALTER PROCEDURE [dbo].[proc_EmployeeBalanceInsert]
(
@EmployeeBalanceID char(36),
@EmployeeID char(36),
@LeaveRegulationID char(36),
@AttendanceTypeID char(36),
@BalanceOpenDate datetime,
@DateFrom datetime,
@DateTo datetime,
@BalanceUpToDate datetime = NULL,
@ValidUntilDate datetime,
@LeaveTransactionTypeID char(1) ,
@TransactionSign int = NULL,
@Days1 decimal(5,2) = NULL,
@Days2 decimal(5,2) = NULL,
@Days3 decimal(5,2) = NULL,
@Days4 decimal(5,2) = NULL,
@Days5 decimal(5,2) = NULL,
@System int = NULL,
@CreationDate datetime = NULL,
@BatchID char(36) = NULL
)
AS
BEGIN
SET NUMERIC_ROUNDABORT on
SET NOCOUNT OFF
DECLARE @Err int
INSERT
INTO [EmployeeBalance]
(
[EmployeeBalanceID], [EmployeeID], [LeaveRegulationID],
[AttendanceTypeID], [BalanceOpenDate], [DateFrom],
[DateTo], [BalanceUpToDate], [ValidUntilDate],
[LeaveTransactionTypeID], [TransactionSign], [Days1],
[Days2], [Days3], [Days4],
[Days5], [System], [CreationDate],
[BatchID]
)
VALUES
(
@EmployeeBalanceID, @EmployeeID, @LeaveRegulationID,
@AttendanceTypeID, @BalanceOpenDate, @DateFrom,
@DateTo, @BalanceUpToDate, @ValidUntilDate,
@LeaveTransactionTypeID, @TransactionSign, @Days1,
@Days2, @Days3, @Days4,
@Days5, @System, @CreationDate,
@BatchID
)
SET @Err = @@Error
RETURN @Err
END
你選擇了你的EDMX您Days1財產什麼類型的? – ken2k 2012-01-12 10:40:27
它的十進制映射是正確的我做了下面的代碼,它的工作,但它的東西不合邏輯:balance.Days1 = Convert.ToDecimal(balance.Days1.ToString(「n2」)); – Mazen313 2012-01-12 10:52:25