//--------------------------------------------------------------------------------------------------- // // 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 UserService.DatabaseLayer.DataModels { /// /// Database : UserService2 /// Data Source : srvbo /// Server Version : 5.5.5-10.3.22-MariaDB-1ubuntu1 /// public partial class UserService2DB : LinqToDB.Data.DataConnection { public ITable IsMemberOfs { get { return this.GetTable(); } } public ITable NodeModels { get { return this.GetTable(); } } public UserService2DB() { InitDataContext(); InitMappingSchema(); } public UserService2DB(string configuration) : base(configuration) { InitDataContext(); InitMappingSchema(); } partial void InitDataContext (); partial void InitMappingSchema(); } [Table("IsMemberOf")] public partial class IsMemberOf { [PrimaryKey(1), NotNull] public int NodeId { get; set; } // int(11) [PrimaryKey(2), NotNull] public int NodeMemberId { get; set; } // int(11) #region Associations /// /// IsMemberOf_ibfk_1 /// [Association(ThisKey="NodeId", OtherKey="Id", CanBeNull=false, Relationship=Relationship.ManyToOne, KeyName="IsMemberOf_ibfk_1", BackReferenceName="IsMemberOfibfks")] public NodeModel Node { get; set; } = null!; /// /// IsMemberOf_ibfk_2 /// [Association(ThisKey="NodeMemberId", OtherKey="Id", CanBeNull=false, Relationship=Relationship.ManyToOne, KeyName="IsMemberOf_ibfk_2", BackReferenceName="IsMemberOfIbfk2BackReferences")] public NodeModel NodeMember { get; set; } = null!; #endregion } [Table("NodeModels")] public partial class NodeModel { [PrimaryKey, Identity ] public int Id { get; set; } // int(11) [Column, NotNull ] public string CommonName { get; set; } = null!; // varchar(64) [Column, Nullable] public string? FirstName { get; set; } // text [Column, Nullable] public string? LastName { get; set; } // text [Column, Nullable] public string? Description { get; set; } // text [Column, Nullable] public int? ParentId { get; set; } // int(11) [Column, Nullable] public int? ManagerId { get; set; } // int(11) [Column, Nullable] public string? EMail { get; set; } // text [Column, NotNull ] public bool IsActive { get; set; } // bit(1) [Column, NotNull ] public string Discriminator { get; set; } = null!; // text #region Associations /// /// NodeModels_ibfk_2_BackReference /// [Association(ThisKey="Id", OtherKey="ManagerId", CanBeNull=true, Relationship=Relationship.OneToMany, IsBackReference=true)] public IEnumerable Ibfks { get; set; } = null!; /// /// IsMemberOf_ibfk_2_BackReference /// [Association(ThisKey="Id", OtherKey="NodeMemberId", CanBeNull=true, Relationship=Relationship.OneToMany, IsBackReference=true)] public IEnumerable IsMemberOfIbfk2BackReferences { get; set; } = null!; /// /// IsMemberOf_ibfk_1_BackReference /// [Association(ThisKey="Id", OtherKey="NodeId", CanBeNull=true, Relationship=Relationship.OneToMany, IsBackReference=true)] public IEnumerable IsMemberOfibfks { get; set; } = null!; /// /// NodeModels_ibfk_2 /// [Association(ThisKey="ManagerId", OtherKey="Id", CanBeNull=true, Relationship=Relationship.ManyToOne, KeyName="NodeModels_ibfk_2", BackReferenceName="Ibfks")] public NodeModel? Manager { get; set; } /// /// NodeModels_ibfk_3_BackReference /// [Association(ThisKey="Id", OtherKey="ParentId", CanBeNull=true, Relationship=Relationship.OneToMany, IsBackReference=true)] public IEnumerable NodeModelsIbfk3BackReferences { get; set; } = null!; /// /// NodeModels_ibfk_3 /// [Association(ThisKey="ParentId", OtherKey="Id", CanBeNull=true, Relationship=Relationship.ManyToOne, KeyName="NodeModels_ibfk_3", BackReferenceName="NodeModelsIbfk3BackReferences")] public NodeModel? Parent { get; set; } #endregion } public static partial class TableExtensions { public static IsMemberOf Find(this ITable table, int NodeId, int NodeMemberId) { return table.FirstOrDefault(t => t.NodeId == NodeId && t.NodeMemberId == NodeMemberId); } public static NodeModel Find(this ITable table, int Id) { return table.FirstOrDefault(t => t.Id == Id); } } } #pragma warning restore 1591