dotnetcore / sharding-core

high performance lightweight solution for efcore sharding table and sharding database support read-write-separation .一款ef-core下高性能、轻量级针对分表分库读写分离的解决方案,具有零依赖、零学习成本、零业务代码入侵
https://xuejmnet.github.io/sharding-core-doc/
Apache License 2.0
1.17k stars 171 forks source link

需求对值对象的支持 #247

Open RuiyanLiu opened 1 year ago

RuiyanLiu commented 1 year ago

public class Category { public Category() { }

    public Guid Id { get; set; }

    [ValueObj]
    public virtual Handler Create { get; set; }

}

public class Handler { public DateTime Time { get; set; }

    public string UserId { get; set; }

}

public void Configure(EntityTypeBuilder builder) { builder.Property(c => c.Id); builder.OwnsOne(p => p.Create,p =>{ p.Property(e => e.UserId).HasComment("创建人");p.Property(e => e.Time).HasComment("创建时间");}); builder.ToTable("Categories"); }

// 需求支持以下这种方式分片 public override void Configure(EntityMetadataTableBuilder builder) { builder.ShardingProperty(o => o.Create.Time); }