Company.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #pragma warning disable CA2227
  2. using System.Collections.Generic;
  3. using System.ComponentModel.DataAnnotations;
  4. using System.ComponentModel.DataAnnotations.Schema;
  5. using Jellyfin.Data.Interfaces;
  6. namespace Jellyfin.Data.Entities.Libraries
  7. {
  8. /// <summary>
  9. /// An entity representing a company.
  10. /// </summary>
  11. public class Company : IHasCompanies, IHasConcurrencyToken
  12. {
  13. /// <summary>
  14. /// Initializes a new instance of the <see cref="Company"/> class.
  15. /// </summary>
  16. /// <param name="owner">The owner of this company.</param>
  17. public Company(IHasCompanies owner)
  18. {
  19. owner?.Companies.Add(this);
  20. CompanyMetadata = new HashSet<CompanyMetadata>();
  21. }
  22. /// <summary>
  23. /// Initializes a new instance of the <see cref="Company"/> class.
  24. /// </summary>
  25. /// <remarks>
  26. /// Default constructor. Protected due to required properties, but present because EF needs it.
  27. /// </remarks>
  28. protected Company()
  29. {
  30. }
  31. /// <summary>
  32. /// Gets or sets the id.
  33. /// </summary>
  34. /// <remarks>
  35. /// Identity, Indexed, Required.
  36. /// </remarks>
  37. [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
  38. public int Id { get; protected set; }
  39. /// <inheritdoc />
  40. [ConcurrencyCheck]
  41. public uint RowVersion { get; set; }
  42. /// <summary>
  43. /// Gets or sets a collection containing the metadata.
  44. /// </summary>
  45. public virtual ICollection<CompanyMetadata> CompanyMetadata { get; protected set; }
  46. /// <summary>
  47. /// Gets or sets a collection containing this company's child companies.
  48. /// </summary>
  49. public virtual ICollection<Company> ChildCompanies { get; protected set; }
  50. /// <inheritdoc />
  51. [NotMapped]
  52. public ICollection<Company> Companies => ChildCompanies;
  53. /// <inheritdoc />
  54. public void OnSavingChanges()
  55. {
  56. RowVersion++;
  57. }
  58. }
  59. }