public void Configure(EntityTypeBuilder <InvoceList> builder) { builder.Property(e => e.BarCode) .HasConversion(e => e.ToString(), e => InvoiceBarCode.Parse(e)); builder.Property(e => e.FileKey) .HasConversion(e => e.ToString(), e => FileKey.Parse(e)); builder.Property <int>("Id").ValueGeneratedOnAdd(); builder.HasKey("Id"); builder.Property <int>("InvoceId"); }
public void Configure(EntityTypeBuilder <SupplyList> builder) { builder.ToTable("SupplyLists", SupplyContextSchemes.Deault); builder.Property(e => e.BarCode) .HasConversion(e => e.ToString(), e => SupplyBarCode.Parse(e)); builder.Property(e => e.FileKey) .HasConversion(e => e.ToString(), e => FileKey.Parse(e)); builder.Property(e => e.FileKey); builder.Property(e => e.BarCode); builder.Property <int>("Id").ValueGeneratedOnAdd(); builder.HasKey("Id"); }
static void Main(string[] args) { var config = BuildConfiguration(); var dbSettings = new SupplyDataContextSettings { ConnectionString = config.GetConnectionString("SqlDataConnection") }; var provider = new ServiceCollection() .AddEfSupplyContext(dbSettings).BuildServiceProvider(); var repo = provider.GetService <IInvoceRepository>(); //===== var goods = new[] { GoodNumber.Parse("G4"), GoodNumber.Parse("G2"), GoodNumber.Parse("G6"), GoodNumber.Parse("G6"), GoodNumber.Parse("G6") }; var invoce = new Invoce("34h-334", "AAA-2", goods); var invoceList = new InvoceList( InvoiceBarCode.Parse("CodeBI-1"), FileKey.Parse("FK-1") ); invoce.WhenListBeScan(invoceList); repo.Save(invoce); var invoces = repo.Query(0, 10, null); }