Finishing to fix repositories

This commit is contained in:
Zoe Roux
2021-03-06 20:21:35 +01:00
parent 76cdbc77a3
commit b907e45a08
21 changed files with 4870 additions and 51 deletions
+49 -7
View File
@@ -3,21 +3,63 @@ using System.Linq.Expressions;
namespace Kyoo.Models
{
public class Link<T1, T2>
where T1 : class, IResource
where T2 : class, IResource
public class Link
{
public static Expression<Func<Link<T1, T2>, object>> PrimaryKey
public int FirstID { get; set; }
public int SecondID { get; set; }
public Link() {}
public Link(IResource first, IResource second)
{
FirstID = first.ID;
SecondID = second.ID;
}
public static Link Create(IResource first, IResource second)
{
return new(first, second);
}
public static Link<T, T2> Create<T, T2>(T first, T2 second)
where T : class, IResource
where T2 : class, IResource
{
return new(first, second);
}
public static Expression<Func<Link, object>> PrimaryKey
{
get
{
return x => new {LibraryID = x.FirstID, ProviderID = x.SecondID};
}
}
public int FirstID { get; set; }
}
public class Link<T1, T2> : Link
where T1 : class, IResource
where T2 : class, IResource
{
public virtual T1 First { get; set; }
public int SecondID { get; set; }
public virtual T2 Second { get; set; }
public Link() {}
public Link(T1 first, T2 second)
: base(first, second)
{
First = first;
Second = second;
}
public new static Expression<Func<Link<T1, T2>, object>> PrimaryKey
{
get
{
return x => new {LibraryID = x.FirstID, ProviderID = x.SecondID};
}
}
}
}
+1 -1
View File
@@ -27,7 +27,7 @@ namespace Kyoo.Models
[EditableRelation] [LoadableRelation] public virtual ICollection<MetadataID> ExternalIDs { get; set; }
public int? StudioID { get; set; }
[SerializeIgnore] public int? StudioID { get; set; }
[LoadableRelation] [EditableRelation] public virtual Studio Studio { get; set; }
[LoadableRelation] [EditableRelation] public virtual ICollection<Genre> Genres { get; set; }
[LoadableRelation] [EditableRelation] public virtual ICollection<PeopleRole> People { get; set; }