#region License // Copyright 2005-2019 Paul Kohler (https://github.com/paulkohler/minisqlquery). All rights reserved. // This source code is made available under the terms of the GNU Lesser General Public License v3.0 // https://github.com/paulkohler/minisqlquery/blob/master/LICENSE #endregion using System.Collections.Generic; using System.Diagnostics; namespace MiniSqlQuery.Core.DbModel { /// The db model table. [DebuggerDisplay("DbModelTable: {FullName} (Columns: {Columns.Count}, PKs: {PrimaryKeyColumns.Count}, FKs: {ForeignKeyColumns.Count})")] public class DbModelTable : DbModelObjectBase { /// Initializes a new instance of the class. public DbModelTable() { Columns = new List(); Constraints = new List(); ObjectType = ObjectTypes.Table; } /// Gets the Columns for this table. /// The columns. public virtual List Columns { get; internal set; } /// Gets Constraints. /// The constraints. public virtual List Constraints { get; private set; } /// Gets ForeignKeyColumns. /// The foreign key columns. public virtual List ForeignKeyColumns { get { return Columns.FindAll(c => c.ForeignKeyReference != null); } } /// Gets NonKeyColumns. /// The non key columns. public virtual List NonKeyColumns { get { return Columns.FindAll(c => !c.IsKey && c.ForeignKeyReference == null); } } /// Gets a reference to the parent database instance. /// The parent model instance object. public virtual DbModelInstance ParentDb { get; internal set; } /// Gets PrimaryKeyColumns. /// The primary key columns. public virtual List PrimaryKeyColumns { get { return Columns.FindAll(c => c.IsKey); } } /// Adds the to the list of assigning the . /// The new column. public virtual void Add(DbModelColumn column) { column.ParentTable = this; Columns.Add(column); } } }