/// <summary> /// Constructs a column. /// </summary> /// <param name="context">The <see cref="IMansionContext"/>.</param> /// <param name="table">The <see cref="Table"/>.</param> /// <param name="propertyName">The name of the property.</param> public NodeStatusPropertyColumn(IMansionContext context, Table table, string propertyName) : base(propertyName) { // validate arguments if (table == null) throw new ArgumentNullException("table"); // create the columns var approvedColumn = BooleanPropertyColumn.CreateBooleanColumn(context, "approved", "approved", new PropertyBag { {"allowNullValue", false}, {"defaultValue", true} }); var publicationDateColumn = DateTimePropertyColumn.CreateDateTimeColumn(context, "publicationDate", "publicationDate", new PropertyBag { {"allowNullValue", false}, {"expression", "{NotNull( Column.value, Now() )}"} }); var expirationDateColumn = DateTimePropertyColumn.CreateDateTimeColumn(context, "expirationDate", "expirationDate", new PropertyBag { {"allowNullValue", false}, {"expression", "{NotNull( Column.value, MaxSqlDate() )}"} }); var archivedColumn = BooleanPropertyColumn.CreateBooleanColumn(context, "archived", "archived", new PropertyBag { {"allowNullValue", false}, {"defaultValue", false} }); // add marker columns table.Add(approvedColumn); table.Add(publicationDateColumn); table.Add(expirationDateColumn); table.Add(archivedColumn); }
/// <summary> /// Constructs a SQL string builder. /// </summary> /// <param name="rootTable"></param> public SqlStringBuilder(Table rootTable) { // validate arguments if (rootTable == null) throw new ArgumentNullException("rootTable"); // set values tables.AppendFormat("[{0}]", rootTable.Name); includedTables.Add(rootTable); this.rootTable = rootTable; }
/// <summary> /// </summary> /// <param name="table"></param> /// <param name="column"></param> public TableColumnPair(Table table, Column column) { // validate arguments if (table == null) throw new ArgumentNullException("table"); if (column == null) throw new ArgumentNullException("column"); // set values Table = table; Column = column; }
/// <summary> /// Generates a statement which joins this table to the given <paramref name="rootTable"/>/ /// </summary> /// <param name="context">The <see cref="IMansionContext"/>.</param> /// <param name="rootTable">The root <see cref="Table"/> to which to join this table.</param> /// <param name="command">The <see cref="SqlCommand"/>.</param> /// <returns>Returns the join statement.</returns> /// <exception cref="ArgumentNullException">Thrown if <paramref name="context"/> or <paramref name="rootTable"/> is null.</exception> public string ToJoinStatement(IMansionContext context, Table rootTable, SqlCommand command) { // validate arguments if (context == null) throw new ArgumentNullException("context"); if (rootTable == null) throw new ArgumentNullException("rootTable"); if (command == null) throw new ArgumentNullException("command"); // invoke template method return DoToJoinStatement(context, rootTable, command); }
/// <summary> /// Constructs a column. /// </summary> /// <param name="table">The <see cref="Table"/>.</param> /// <param name="propertyName">The name of the property.</param> public NodePointerPropertyColumn(Table table, string propertyName) : base(propertyName, propertyName, 150) { // validate arguments if (table == null) throw new ArgumentNullException("table"); // add marker columns table.Add(new VirtualColumn("name")); table.Add(new VirtualColumn("type")); table.Add(new VirtualColumn("depth")); table.Add(new VirtualColumn("parentId")); table.Add(new VirtualColumn("parentPointer")); table.Add(new VirtualColumn("parentPath")); table.Add(new VirtualColumn("parentStructure")); }
/// <summary> /// Adds the table to the query. /// </summary> /// <param name="context">The <see cref="IMansionContext"/>.</param> /// <param name="command">The <see cref="SqlCommand"/>.</param> /// <param name="table">The <see cref="Table"/> which to add.</param> public void AddTable(IMansionContext context, Table table, SqlCommand command) { // validate arguments if (context == null) throw new ArgumentNullException("context"); if (table == null) throw new ArgumentNullException("table"); if (command == null) throw new ArgumentNullException("command"); // check if the table is already included if (includedTables.Contains(table)) return; includedTables.Add(table); tables.Append(" " + table.ToJoinStatement(context, rootTable, command)); }
/// <summary> /// Generates a statement which joins this table to the given <paramref name="rootTable"/>/ /// </summary> /// <param name="context">The <see cref="IMansionContext"/>.</param> /// <param name="rootTable">The root <see cref="Table"/> to which to join this table.</param> /// <param name="command">The <see cref="SqlCommand"/>.</param> /// <returns>Returns the join statement.</returns> /// <exception cref="ArgumentNullException">Thrown if <paramref name="context"/> or <paramref name="rootTable"/> is null.</exception> protected virtual string DoToJoinStatement(IMansionContext context, Table rootTable, SqlCommand command) { return string.Format("INNER JOIN [{0}] ON [{0}].[id] = [{1}].[id]", Name, rootTable.Name); }