John John
John John

Reputation: 1

converting between Biginit & Long & Int64 is it safe

I have a column inside sql server 2008 r2 of type Biginit, and when i map the sql server table using entity framework, it automatically assign the Biginit a long datatype. my question is weather such conversion is correct or should be overridden ? in other words is SQL server 2008 Biginit 100% equivalent to .Net Long ? second question is .Net Long 100% equivalent to .Net Int64 ?

Upvotes: 1

Views: 1451

Answers (3)

GvS
GvS

Reputation: 52518

For .Net

The internal .Net datatype is Int64. This is a 64 bit signed integer. long is an alias for Int64. Probably because it looks more C#-ish.

For SQL

BigInt is also a 64bit signed integer. It is essentially the same (has the same domain/range) as other signed 64-bit integer types. With one exception, BigInt can have a null value, and has this behavior by default.

So actually:

  • BigInt = long? = Nullable<long>
  • BigInt NOT NULL = long

Upvotes: 2

CodingIntrigue
CodingIntrigue

Reputation: 78555

SQL's bigint is equivalent to C#'s Int64.

long is just syntactic sugar for Int64, same as string and String or int and Int32.

So bigint == long == Int64.

Upvotes: 3

Magnus
Magnus

Reputation: 46967

Yes, SQL server BigInt = .NET Int64 = C# long

Upvotes: 1

Related Questions