Skip to content

Commit e900bac

Browse files
committed
feat(example): add attrs to models
1 parent 8e17056 commit e900bac

File tree

5 files changed

+119
-0
lines changed

5 files changed

+119
-0
lines changed

src/JsonApiDotNetCoreExample/Migrations/20161223031653_AddAttributes.Designer.cs

Lines changed: 58 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using Microsoft.EntityFrameworkCore.Migrations;
4+
5+
namespace JsonApiDotNetCoreExample.Migrations
6+
{
7+
public partial class AddAttributes : Migration
8+
{
9+
protected override void Up(MigrationBuilder migrationBuilder)
10+
{
11+
migrationBuilder.AddColumn<string>(
12+
name: "Description",
13+
table: "TodoItems",
14+
nullable: true);
15+
16+
migrationBuilder.AddColumn<string>(
17+
name: "FirstName",
18+
table: "People",
19+
nullable: true);
20+
21+
migrationBuilder.AddColumn<string>(
22+
name: "LastName",
23+
table: "People",
24+
nullable: true);
25+
}
26+
27+
protected override void Down(MigrationBuilder migrationBuilder)
28+
{
29+
migrationBuilder.DropColumn(
30+
name: "Description",
31+
table: "TodoItems");
32+
33+
migrationBuilder.DropColumn(
34+
name: "FirstName",
35+
table: "People");
36+
37+
migrationBuilder.DropColumn(
38+
name: "LastName",
39+
table: "People");
40+
}
41+
}
42+
}

src/JsonApiDotNetCoreExample/Migrations/AppDbContextModelSnapshot.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ protected override void BuildModel(ModelBuilder modelBuilder)
2121
b.Property<int>("Id")
2222
.ValueGeneratedOnAdd();
2323

24+
b.Property<string>("FirstName");
25+
26+
b.Property<string>("LastName");
27+
2428
b.HasKey("Id");
2529

2630
b.ToTable("People");
@@ -31,6 +35,8 @@ protected override void BuildModel(ModelBuilder modelBuilder)
3135
b.Property<int>("Id")
3236
.ValueGeneratedOnAdd();
3337

38+
b.Property<string>("Description");
39+
3440
b.Property<int?>("OwnerId");
3541

3642
b.HasKey("Id");
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
using System.Collections.Generic;
2+
using JsonApiDotNetCore.Internal;
23
using JsonApiDotNetCore.Models;
34

45
namespace JsonApiDotNetCoreExample.Models
56
{
67
public class Person : IIdentifiable
78
{
89
public int Id { get; set; }
10+
11+
[Attr("firstName")]
12+
public string FirstName { get; set; }
13+
14+
[Attr("lastName")]
15+
public string LastName { get; set; }
16+
917
public virtual List<TodoItem> TodoItems { get; set; }
1018
}
1119
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1+
using JsonApiDotNetCore.Internal;
12
using JsonApiDotNetCore.Models;
23

34
namespace JsonApiDotNetCoreExample.Models
45
{
56
public class TodoItem : IIdentifiable
67
{
78
public int Id { get; set; }
9+
10+
[Attr("description")]
11+
public string Description { get; set; }
12+
813
public virtual Person Owner { get; set; }
914
}
1015
}

0 commit comments

Comments
 (0)