EntityFrameworkCore将数据库Timestamp类型在程序中转为long类型

时间:2025-05-10 08:05:25

EntityFrameworkCore将数据库Timestamp类型在程序中转为long类型

EntityFrameworkCore

Entity

public class Entity
{
public ulong RowVersion { get; set; } // anymore byte[]
}

Context

modelBuilder.Entity<Entity>(entity =>
{
entity
.Property(e => e.RowVersion)
.HasConversion(new NumberToBytesConverter<ulong>())
.IsRowVersion();
});

In Query

ulong sinceRowVersion;

...
.Where(e => e.RowVersion > sinceRowVersion);
...