Skip to content

Commit ff09ae7

Browse files
committed
support bulk add transaction
- rename replace to update - rollback failed transactions
1 parent c8c4477 commit ff09ae7

32 files changed

+408
-310
lines changed

Directory.Build.props

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<Project>
2-
2+
33
<PropertyGroup>
44
<NetCoreAppVersion>netcoreapp2.0</NetCoreAppVersion>
55
<NetStandardVersion>netstandard2.0</NetStandardVersion>
@@ -10,7 +10,6 @@
1010
<MicrosoftConfigurationVersion>2.0.0</MicrosoftConfigurationVersion>
1111
<MicrosoftOptionsVersion>2.0.0</MicrosoftOptionsVersion>
1212

13-
1413
<EFCoreVersion>2.0.1</EFCoreVersion>
1514
<EFCoreToolsVersion>2.0.1</EFCoreToolsVersion>
1615

@@ -19,14 +18,14 @@
1918

2019
<TuplesVersion>4.4.0</TuplesVersion>
2120
</PropertyGroup>
22-
23-
<!-- Test Project Dependencies -->
21+
22+
<!-- Test Project Dependencies -->
2423
<PropertyGroup>
2524
<TestSdkVersion>15.3.0-preview-20170427-09</TestSdkVersion>
2625
<TestHostVersion>1.1.2</TestHostVersion>
2726
<XUnitVersion>2.3.0-beta3-build3705</XUnitVersion>
2827
<BogusVersion>15.0.3</BogusVersion>
2928
<MoqVersion>4.7.99</MoqVersion>
3029
</PropertyGroup>
31-
30+
3231
</Project>

src/Examples/OperationsExample/Data/AppDbContext.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ public AppDbContext(DbContextOptions<AppDbContext> options)
1010
{ }
1111

1212
public DbSet<Article> Articles { get; set; }
13+
public DbSet<Author> Authors { get; set; }
1314
}
1415
}

src/Examples/OperationsExample/Migrations/20170827234334_AddArticles.Designer.cs

Lines changed: 0 additions & 33 deletions
This file was deleted.

src/Examples/OperationsExample/Migrations/20170827234334_AddArticles.cs

Lines changed: 0 additions & 32 deletions
This file was deleted.

src/Examples/OperationsExample/Migrations/20180325130426_ArticlesAndAuthors.Designer.cs

Lines changed: 61 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
using Microsoft.EntityFrameworkCore.Metadata;
2+
using Microsoft.EntityFrameworkCore.Migrations;
3+
using System;
4+
using System.Collections.Generic;
5+
6+
namespace OperationsExample.Migrations
7+
{
8+
public partial class ArticlesAndAuthors : Migration
9+
{
10+
protected override void Up(MigrationBuilder migrationBuilder)
11+
{
12+
migrationBuilder.CreateTable(
13+
name: "Authors",
14+
columns: table => new
15+
{
16+
Id = table.Column<int>(nullable: false)
17+
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn),
18+
Name = table.Column<string>(nullable: true)
19+
},
20+
constraints: table =>
21+
{
22+
table.PrimaryKey("PK_Authors", x => x.Id);
23+
});
24+
25+
migrationBuilder.CreateTable(
26+
name: "Articles",
27+
columns: table => new
28+
{
29+
Id = table.Column<int>(nullable: false)
30+
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn),
31+
AuthorId = table.Column<int>(nullable: true),
32+
Name = table.Column<string>(nullable: true)
33+
},
34+
constraints: table =>
35+
{
36+
table.PrimaryKey("PK_Articles", x => x.Id);
37+
table.ForeignKey(
38+
name: "FK_Articles_Authors_AuthorId",
39+
column: x => x.AuthorId,
40+
principalTable: "Authors",
41+
principalColumn: "Id",
42+
onDelete: ReferentialAction.Restrict);
43+
});
44+
45+
migrationBuilder.CreateIndex(
46+
name: "IX_Articles_AuthorId",
47+
table: "Articles",
48+
column: "AuthorId");
49+
}
50+
51+
protected override void Down(MigrationBuilder migrationBuilder)
52+
{
53+
migrationBuilder.DropTable(
54+
name: "Articles");
55+
56+
migrationBuilder.DropTable(
57+
name: "Authors");
58+
}
59+
}
60+
}
Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
using System;
1+
// <auto-generated />
22
using Microsoft.EntityFrameworkCore;
33
using Microsoft.EntityFrameworkCore.Infrastructure;
44
using Microsoft.EntityFrameworkCore.Metadata;
55
using Microsoft.EntityFrameworkCore.Migrations;
6+
using Microsoft.EntityFrameworkCore.Storage;
7+
using Microsoft.EntityFrameworkCore.Storage.Internal;
68
using OperationsExample.Data;
9+
using System;
710

811
namespace OperationsExample.Migrations
912
{
@@ -12,21 +15,46 @@ partial class AppDbContextModelSnapshot : ModelSnapshot
1215
{
1316
protected override void BuildModel(ModelBuilder modelBuilder)
1417
{
18+
#pragma warning disable 612, 618
1519
modelBuilder
1620
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn)
17-
.HasAnnotation("ProductVersion", "1.1.2");
21+
.HasAnnotation("ProductVersion", "2.0.1-rtm-125");
1822

1923
modelBuilder.Entity("OperationsExample.Models.Article", b =>
2024
{
2125
b.Property<int>("Id")
2226
.ValueGeneratedOnAdd();
2327

28+
b.Property<int?>("AuthorId");
29+
2430
b.Property<string>("Name");
2531

2632
b.HasKey("Id");
2733

34+
b.HasIndex("AuthorId");
35+
2836
b.ToTable("Articles");
2937
});
38+
39+
modelBuilder.Entity("OperationsExample.Models.Author", b =>
40+
{
41+
b.Property<int>("Id")
42+
.ValueGeneratedOnAdd();
43+
44+
b.Property<string>("Name");
45+
46+
b.HasKey("Id");
47+
48+
b.ToTable("Authors");
49+
});
50+
51+
modelBuilder.Entity("OperationsExample.Models.Article", b =>
52+
{
53+
b.HasOne("OperationsExample.Models.Author", "Author")
54+
.WithMany("Articles")
55+
.HasForeignKey("AuthorId");
56+
});
57+
#pragma warning restore 612, 618
3058
}
3159
}
3260
}
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1-
using JsonApiDotNetCore.Models;
1+
using JsonApiDotNetCore.Models;
22

33
namespace OperationsExample.Models
44
{
55
public class Article : Identifiable
66
{
77
[Attr("name")]
8-
public string Name { get; set; }
8+
public string Name { get; set; }
9+
10+
[HasOne("author")]
11+
public Author Author { get; set; }
12+
public int AuthorId { get; set; }
913
}
1014
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using JsonApiDotNetCore.Models;
2+
using System.Collections.Generic;
3+
4+
namespace OperationsExample.Models
5+
{
6+
public class Author : Identifiable
7+
{
8+
[Attr("name")]
9+
public string Name { get; set; }
10+
11+
[HasMany("articles")]
12+
public List<Article> Articles { get; set; }
13+
}
14+
}

src/Examples/OperationsExample/OperationsExample.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
</ItemGroup>
1212

1313
<ItemGroup>
14+
<PackageReference Include="Microsoft.AspNetCore" Version="$(AspNetCoreVersion)" />
1415
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="$(AspNetCoreVersion)" />
1516
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="$(MicrosoftConfigurationVersion)" />
1617
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="$(MicrosoftConfigurationVersion)" />

0 commit comments

Comments
 (0)