Adding expression rewrite attributes to every item's link

This commit is contained in:
Zoe Roux 2020-09-13 15:26:56 +02:00
parent c42805e415
commit 3ad5096d21
3 changed files with 6 additions and 1 deletions

View File

@ -8,6 +8,7 @@ namespace Kyoo.Models
public class CollectionDE : Collection public class CollectionDE : Collection
{ {
[JsonIgnore] [NotMergable] public virtual IEnumerable<CollectionLink> Links { get; set; } [JsonIgnore] [NotMergable] public virtual IEnumerable<CollectionLink> Links { get; set; }
[ExpressionRewrite(nameof(Links), nameof(CollectionLink.Show))]
public override IEnumerable<Show> Shows public override IEnumerable<Show> Shows
{ {
get => Links?.Select(x => x.Show); get => Links?.Select(x => x.Show);

View File

@ -8,6 +8,7 @@ namespace Kyoo.Models
public class LibraryDE : Library public class LibraryDE : Library
{ {
[JsonIgnore] [NotMergable] public virtual IEnumerable<ProviderLink> ProviderLinks { get; set; } [JsonIgnore] [NotMergable] public virtual IEnumerable<ProviderLink> ProviderLinks { get; set; }
[ExpressionRewrite(nameof(ProviderLinks), nameof(ProviderLink.Provider))]
public override IEnumerable<ProviderID> Providers public override IEnumerable<ProviderID> Providers
{ {
get => ProviderLinks?.Select(x => x.Provider); get => ProviderLinks?.Select(x => x.Provider);
@ -15,6 +16,7 @@ namespace Kyoo.Models
} }
[JsonIgnore] [NotMergable] public virtual IEnumerable<LibraryLink> Links { get; set; } [JsonIgnore] [NotMergable] public virtual IEnumerable<LibraryLink> Links { get; set; }
[ExpressionRewrite(nameof(Links), nameof(LibraryLink.Show))]
public override IEnumerable<Show> Shows public override IEnumerable<Show> Shows
{ {
get => Links?.Where(x => x.Show != null).Select(x => x.Show); get => Links?.Where(x => x.Show != null).Select(x => x.Show);
@ -22,6 +24,7 @@ namespace Kyoo.Models
value?.Select(x => new LibraryLink(this, x)), value?.Select(x => new LibraryLink(this, x)),
Links?.Where(x => x.Show == null)); Links?.Where(x => x.Show == null));
} }
[ExpressionRewrite(nameof(Links), nameof(LibraryLink.Collection))]
public override IEnumerable<Collection> Collections public override IEnumerable<Collection> Collections
{ {
get => Links?.Where(x => x.Collection != null).Select(x => x.Collection); get => Links?.Where(x => x.Collection != null).Select(x => x.Collection);

View File

@ -19,6 +19,7 @@ namespace Kyoo.Models
} }
[JsonIgnore] [NotMergable] public virtual IEnumerable<LibraryLink> LibraryLinks { get; set; } [JsonIgnore] [NotMergable] public virtual IEnumerable<LibraryLink> LibraryLinks { get; set; }
[ExpressionRewrite(nameof(LibraryLinks), nameof(LibraryLink.Library))]
public override IEnumerable<Library> Libraries public override IEnumerable<Library> Libraries
{ {
get => LibraryLinks?.Select(x => x.Library); get => LibraryLinks?.Select(x => x.Library);
@ -26,7 +27,7 @@ namespace Kyoo.Models
} }
[JsonIgnore] [NotMergable] public virtual IEnumerable<CollectionLink> CollectionLinks { get; set; } [JsonIgnore] [NotMergable] public virtual IEnumerable<CollectionLink> CollectionLinks { get; set; }
[ExpressionRewrite(nameof(CollectionLinks), nameof(CollectionLink.Collection))]
public override IEnumerable<Collection> Collections public override IEnumerable<Collection> Collections
{ {
get => CollectionLinks?.Select(x => x.Collection); get => CollectionLinks?.Select(x => x.Collection);