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

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

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);
...
原文地址:https://www.cnblogs.com/oneweek/p/10038563.html