In the debug logs EF Core shows timestamps in the same format that they appear in SQL Server Management Studio. I needed to be able to convert the byte[8]
for timestamp
/ rowversion
to the same format for comparison.
eg. optimistic concurrency checks you'll see parameters like this.
@p3='0x0000000005B7566B'
After a lot of poking around in the source code for EF Core and not finding where they do it I eventually found this very simple way:
Convert.ToHexString(order.RowVersion)// gives 8 bytesConvert.FromHexString("0000000005B7566B") // don't include the 0x
PS. I never really understood these "AAAxxx==" timestamps. How is that a helpful format for anyone?