Skip to content

Commit 2cc6e3a

Browse files
committed
feat(identifiable): make id member virtual
see #40 for discussion
1 parent 36e3836 commit 2cc6e3a

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,17 @@ public class Person : Identifiable
8686
{ }
8787
```
8888

89+
If you need to hang annotations or attributes on the `Id` property, you can override the virtual member:
90+
91+
```csharp
92+
public class Person : Identifiable
93+
{
94+
[Key]
95+
[Column("person_id")]
96+
public override int Id { get; set; }
97+
}
98+
```
99+
89100
#### Specifying Public Attributes
90101

91102
If you want an attribute on your model to be publicly available,

src/JsonApiDotNetCore/Models/Identifiable.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ public class Identifiable : Identifiable<int>
55

66
public class Identifiable<T> : IIdentifiable<T>, IIdentifiable
77
{
8-
public T Id { get; set; }
8+
public virtual T Id { get; set; }
99

1010
object IIdentifiable.Id
1111
{

0 commit comments

Comments
 (0)