RowVersion for SQL Server
Pineapple.Data.RowVersion turns SQL Server’s 8-byte rowversion into a comparable, sortable struct. EF Core and ADO.NET surface rowversion columns as byte[], which can’t be compared with < or >; RowVersion can.
using Pineapple.Data;
RowVersion current = (RowVersion)entity.Version; // byte[] from EF Core
RowVersion watermark = lastSyncedVersion; // implicit from long/ulong
if (current > watermark)
{
await SyncAsync(entity);
watermark = RowVersion.Max(watermark, current);
}
byte[] bytes = watermark; // implicit back to byte[] (big-endian)
Console.WriteLine(watermark); // "00000000000007d1"
API
| Member | Purpose |
|---|---|
RowVersion.Zero, MinValue, MaxValue |
Constants |
(RowVersion)byte[], (RowVersion?)byte[] |
Explicit from 8 big-endian bytes (null → null for the nullable form) |
implicit from long / ulong |
Construct from a number |
implicit to byte[] |
8 big-endian bytes |
==, !=, <, <=, >, >=, CompareTo |
Comparison |
RowVersion.Max(a, b) |
Larger of two values |
ToString() |
16-digit lowercase hex |