//--------------------------------------------------------------------------------------------------- // // This code was generated by T4Model template for T4 (https://github.com/linq2db/linq2db). // Changes to this file may cause incorrect behavior and will be lost if the code is regenerated. // //--------------------------------------------------------------------------------------------------- #pragma warning disable 1591 #nullable enable using System; using System.Collections.Generic; using System.Linq; using LinqToDB; using LinqToDB.Mapping; namespace DataModels { /// /// Database : UserService /// Data Source : srvbo /// Server Version : 5.5.5-10.3.22-MariaDB-1ubuntu1 /// public partial class UserServiceDB : LinqToDB.Data.DataConnection { public ITable Members { get { return this.GetTable(); } } public ITable MembersMembers { get { return this.GetTable(); } } public ITable Nodes { get { return this.GetTable(); } } public ITable OrganizationUnits { get { return this.GetTable(); } } public ITable SecurityGroups { get { return this.GetTable(); } } public ITable Users { get { return this.GetTable(); } } public UserServiceDB() { InitDataContext(); InitMappingSchema(); } public UserServiceDB(string configuration) : base(configuration) { InitDataContext(); InitMappingSchema(); } partial void InitDataContext (); partial void InitMappingSchema(); } [Table("Members")] public partial class Member { [Column, NotNull] public int Id { get; set; } // int(11) #region Associations /// /// MembersMember_ibfk_2_BackReference /// [Association(ThisKey="Id", OtherKey="AttachedMemberId", CanBeNull=true, Relationship=Relationship.OneToMany, IsBackReference=true)] public IEnumerable MembersMemberibfks { get; set; } = null!; /// /// Members_ibfk_2 /// [Association(ThisKey="Id", OtherKey="Id", CanBeNull=false, Relationship=Relationship.ManyToOne, KeyName="Members_ibfk_2", BackReferenceName="Membersibfks")] public Node Node { get; set; } = null!; /// /// SecurityGroups_ibfk_2_BackReference /// [Association(ThisKey="Id", OtherKey="Id", CanBeNull=true, Relationship=Relationship.OneToMany, IsBackReference=true)] public IEnumerable SecurityGroupsibfks { get; set; } = null!; /// /// Users_ibfk_2_BackReference /// [Association(ThisKey="Id", OtherKey="Id", CanBeNull=true, Relationship=Relationship.OneToMany, IsBackReference=true)] public IEnumerable Usersibfks { get; set; } = null!; #endregion } [Table("MembersMember")] public partial class MembersMember { [PrimaryKey(1), NotNull] public int MemberId { get; set; } // int(11) [PrimaryKey(2), NotNull] public int AttachedMemberId { get; set; } // int(11) #region Associations /// /// MembersMember_ibfk_2 /// [Association(ThisKey="AttachedMemberId", OtherKey="Id", CanBeNull=false, Relationship=Relationship.ManyToOne, KeyName="MembersMember_ibfk_2", BackReferenceName="MembersMemberibfks")] public Member AttachedMember { get; set; } = null!; /// /// MembersMember_ibfk_3 /// [Association(ThisKey="MemberId", OtherKey="Id", CanBeNull=false, Relationship=Relationship.ManyToOne, KeyName="MembersMember_ibfk_3", BackReferenceName="MembersMemberibfks")] public SecurityGroup Member { get; set; } = null!; #endregion } [Table("Nodes")] public partial class Node { [PrimaryKey, Identity] public int Id { get; set; } // int(11) [Column, NotNull ] public string CommonName { get; set; } = null!; // text #region Associations /// /// Members_ibfk_2_BackReference /// [Association(ThisKey="Id", OtherKey="Id", CanBeNull=true, Relationship=Relationship.OneToMany, IsBackReference=true)] public IEnumerable Membersibfks { get; set; } = null!; /// /// OrganizationUnits_ibfk_2_BackReference /// [Association(ThisKey="Id", OtherKey="Id", CanBeNull=true, Relationship=Relationship.OneToMany, IsBackReference=true)] public IEnumerable OrganizationUnitsibfks { get; set; } = null!; #endregion } [Table("OrganizationUnits")] public partial class OrganizationUnit { [Column, NotNull ] public int Id { get; set; } // int(11) [Column, Nullable] public int? ManagerId { get; set; } // int(11) [Column, Nullable] public int? ParentId { get; set; } // int(11) #region Associations /// /// OrganizationUnits_ibfk_3_BackReference /// [Association(ThisKey="Id", OtherKey="ParentId", CanBeNull=true, Relationship=Relationship.OneToMany, IsBackReference=true)] public IEnumerable Ibfks { get; set; } = null!; /// /// OrganizationUnits_ibfk_2 /// [Association(ThisKey="Id", OtherKey="Id", CanBeNull=false, Relationship=Relationship.ManyToOne, KeyName="OrganizationUnits_ibfk_2", BackReferenceName="OrganizationUnitsibfks")] public Node Node { get; set; } = null!; /// /// OrganizationUnits_ibfk_3 /// [Association(ThisKey="ParentId", OtherKey="Id", CanBeNull=true, Relationship=Relationship.ManyToOne, KeyName="OrganizationUnits_ibfk_3", BackReferenceName="Ibfks")] public OrganizationUnit? Parent { get; set; } #endregion } [Table("SecurityGroups")] public partial class SecurityGroup { [Column, NotNull] public int Id { get; set; } // int(11) #region Associations /// /// SecurityGroups_ibfk_2 /// [Association(ThisKey="Id", OtherKey="Id", CanBeNull=false, Relationship=Relationship.ManyToOne, KeyName="SecurityGroups_ibfk_2", BackReferenceName="SecurityGroupsibfks")] public Member Member { get; set; } = null!; /// /// MembersMember_ibfk_3_BackReference /// [Association(ThisKey="Id", OtherKey="MemberId", CanBeNull=true, Relationship=Relationship.OneToMany, IsBackReference=true)] public IEnumerable MembersMemberibfks { get; set; } = null!; #endregion } [Table("Users")] public partial class User { [Column, NotNull ] public int Id { get; set; } // int(11) [Column, Nullable] public string? FirstName { get; set; } // text [Column, Nullable] public string? LastName { get; set; } // text [Column, NotNull ] public bool IsActive { get; set; } // bit(1) #region Associations /// /// Users_ibfk_2 /// [Association(ThisKey="Id", OtherKey="Id", CanBeNull=false, Relationship=Relationship.ManyToOne, KeyName="Users_ibfk_2", BackReferenceName="Usersibfks")] public Member Member { get; set; } = null!; #endregion } public static partial class TableExtensions { public static MembersMember Find(this ITable table, int MemberId, int AttachedMemberId) { return table.FirstOrDefault(t => t.MemberId == MemberId && t.AttachedMemberId == AttachedMemberId); } public static Node Find(this ITable table, int Id) { return table.FirstOrDefault(t => t.Id == Id); } } } #pragma warning restore 1591