-
-
Notifications
You must be signed in to change notification settings - Fork 158
Feat/#151: Many-to-Many Support via [HasManyThrough] #413
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
3814d5e
8d887fa
6fc162f
8a69eff
23dbad0
14d175b
11b0cc2
985342f
542b021
1fa4605
dc8453e
9c52b77
412ab89
edbbd42
1da949c
3c20861
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using JsonApiDotNetCore.Controllers; | ||
using JsonApiDotNetCore.Services; | ||
using JsonApiDotNetCoreExample.Models; | ||
|
||
namespace JsonApiDotNetCoreExample.Controllers | ||
{ | ||
public class ArticlesController : JsonApiController<Article> | ||
{ | ||
public ArticlesController( | ||
IJsonApiContext jsonApiContext, | ||
IResourceService<Article> resourceService) | ||
: base(jsonApiContext, resourceService) | ||
{ } | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
using System.Collections.Generic; | ||
using System.ComponentModel.DataAnnotations.Schema; | ||
using JsonApiDotNetCore.Models; | ||
|
||
namespace JsonApiDotNetCoreExample.Models | ||
|
@@ -10,5 +12,10 @@ public class Article : Identifiable | |
[HasOne("author")] | ||
public Author Author { get; set; } | ||
public int AuthorId { get; set; } | ||
|
||
[NotMapped] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is really interesting @jaredcnance. Is the idea here that you include a List to the other side as well as the joining entity? I think that makes sense from the ability to be generic about it. I think I'll update my entity/resource example to do this as well, see how it works there. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep. In the case of a separate resource class, the |
||
[HasManyThrough(nameof(ArticleTags))] | ||
public List<Tag> Tags { get; set; } | ||
public List<ArticleTag> ArticleTags { get; set; } | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
namespace JsonApiDotNetCoreExample.Models | ||
{ | ||
public class ArticleTag | ||
{ | ||
public int ArticleId { get; set; } | ||
public Article Article { get; set; } | ||
|
||
public int TagId { get; set; } | ||
public Tag Tag { get; set; } | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using JsonApiDotNetCore.Models; | ||
|
||
namespace JsonApiDotNetCoreExample.Models | ||
{ | ||
public class Tag : Identifiable | ||
{ | ||
public string Name { get; set; } | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hah. Great catch!