converting sql server rowversion to long or ulong?

后端 未结 4 785
隐瞒了意图╮
隐瞒了意图╮ 2020-12-18 21:14

What is the proper type for the rowversion (timestamp) data type?

I know it is 8 bytes but i cannot find a link in MSDN which tell if it is a signed or unsigned long

4条回答
  •  被撕碎了的回忆
    2020-12-18 21:54

    Neither will work correctly for purposes of comparing timestamp/rowversion values, if you're running on an x86 family CPU, because of endian. The first byte of a timestamp is most significant, but not so for little endian integer types.

    Call Array.Reverse(ts) before calling BitConverter.ToUInt64(ts), and for the other direction, after calling BitConverter.GetBytes(tsUInt64)

提交回复
热议问题