問題:
So I have a table with an identity column as the primary key, so it is an integer.所以我有一個以標識列作爲主鍵的表,所以它是一個整數。 So, why does SCOPE_IDENTITY()
always return a decimal value instead of an int to my C# application?那麼,爲什麼SCOPE_IDENTITY()
總是向我的 C# 應用程序返回一個十進制值而不是一個 int 值? This is really annoying since decimal values will not implicitly convert to integers in C#, which means I now have to rewrite a bunch of stuff and have a lot of helper methods because I use SQL Server and Postgres, which Postgres does return an integer for the equivalent function..這真的很煩人,因爲十進制值不會在 C# 中隱式轉換爲整數,這意味着我現在必須重寫一堆東西並有很多幫助方法,因爲我使用 SQL Server 和 Postgres,Postgres 確實爲等效功能..
Why does SCOPE_IDENTITY()
not just return a plain integer?爲什麼SCOPE_IDENTITY()
不只是返回一個普通的整數? Are there people out there that commonly use decimal/non-identity values for primary keys?有沒有人通常使用十進制/非身份值作爲主鍵?