Company.cs 2.0 KB

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