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

2019-04-16 16:23:42 浏览数 (1)

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

EntityFrameworkCore

Entity

代码语言:javascript复制
public class Entity
{
    public ulong RowVersion { get; set; } // anymore byte[]
}

Context

代码语言:javascript复制
modelBuilder.Entity<Entity>(entity =>
{
     entity
         .Property(e => e.RowVersion)
         .HasConversion(new NumberToBytesConverter<ulong>())
         .IsRowVersion();
});

In Query

代码语言:javascript复制
ulong sinceRowVersion;

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

0 人点赞