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);
...
posted @ 2018-11-29 15:23  oneweek  阅读(734)  评论(0编辑  收藏  举报