/// <summary> /// Adds into this builder a new entry using the given one, optionally cloning it, along /// with the value to be held by its associated column. /// </summary> /// <param name="entry">The schema entry.</param> /// <param name="value">The value of the column.</param> /// <param name="cloneEntry">True to clone the given entry</param> public void AddEntry(ISchemaEntry entry, object value, bool cloneEntry = true) { if (IsDisposed) { throw new ObjectDisposedException(this.ToString()); } if (entry == null) { throw new ArgumentNullException("entry", "Entry cannot be null."); } if (entry.IsDisposed) { throw new ObjectDisposedException(entry.ToString()); } if (cloneEntry) { entry = entry.Clone(); } _Schema.Add(entry); _Values.Add(value); }
/// <summary> /// Adds into this builder a new entry using the given one, optionally cloning it, along /// with the value to be held by its associated column. /// </summary> /// <param name="entry">The schema entry.</param> /// <param name="value">The value of the column.</param> /// <param name="cloneEntry">True to clone the given entry</param> public void AddEntry(ISchemaEntry entry, object value, bool cloneEntry = true) { if (IsDisposed) throw new ObjectDisposedException(this.ToString()); if (entry == null) throw new ArgumentNullException("entry", "Entry cannot be null."); if (entry.IsDisposed) throw new ObjectDisposedException(entry.ToString()); if (cloneEntry) entry = entry.Clone(); _Schema.Add(entry); _Values.Add(value); }
/// <summary> /// Adds the given orphan instance into this collection. /// </summary> /// <param name="member">The orphan instance to add into this collection.</param> public void Add(ISchemaEntry member) { if (IsDisposed) { throw new ObjectDisposedException(this.ToString()); } if (member == null) { throw new ArgumentNullException("member", "Member cannot be null."); } if (member.IsDisposed) { throw new ObjectDisposedException(member.ToString()); } if (object.ReferenceEquals(this, member.Owner)) { return; } if (member.Owner != null) { throw new NotOrphanException( "Cannot add member '{0}' into this '{1}' because it is not orphan." .FormatWith(member, this)); } Core.SchemaEntry.ValidateTable(member.TableName); Core.SchemaEntry.ValidateColumn(member.ColumnName); var alias = (IElementAlias)(member.TableName == null ? null : Aliases.FindAlias(member.TableName)); if (alias != null) { member.TableName = alias.Element; } var temp = FindEntry(member.TableName, member.ColumnName); if (temp != null) { throw new DuplicateException( "Cannot add member '{0}' into this '{1}' because its name is already used." .FormatWith(member, this)); } var list = FindColumn(member.ColumnName).ToList(); if (list.Count != 0) { if (member.TableName == null) { throw new DuplicateException( "Cannot add member '{0}' into this '{1}' because its column is already used in a non-default table." .FormatWith(member, this)); } temp = list.Find(x => x.TableName == null); if (temp != null) { throw new DuplicateException( "Cannot add member '{0}' into this '{1}' because its name is already used in the default table." .FormatWith(member, this)); } } _Members.Add(member); // To intercept re-entrant operation... member.Owner = this; }
/// <summary> /// Adds the given orphan instance into this collection. /// </summary> /// <param name="member">The orphan instance to add into this collection.</param> public void Add(ISchemaEntry member) { if (IsDisposed) throw new ObjectDisposedException(this.ToString()); if (member == null) throw new ArgumentNullException("member", "Member cannot be null."); if (member.IsDisposed) throw new ObjectDisposedException(member.ToString()); if (object.ReferenceEquals(this, member.Owner)) return; if (member.Owner != null) throw new NotOrphanException( "Cannot add member '{0}' into this '{1}' because it is not orphan." .FormatWith(member, this)); Core.SchemaEntry.ValidateTable(member.TableName); Core.SchemaEntry.ValidateColumn(member.ColumnName); var alias = (IElementAlias)(member.TableName == null ? null : Aliases.FindAlias(member.TableName)); if (alias != null) member.TableName = alias.Element; var temp = FindEntry(member.TableName, member.ColumnName); if (temp != null) throw new DuplicateException( "Cannot add member '{0}' into this '{1}' because its name is already used." .FormatWith(member, this)); var list = FindColumn(member.ColumnName).ToList(); if (list.Count != 0) { if (member.TableName == null) throw new DuplicateException( "Cannot add member '{0}' into this '{1}' because its column is already used in a non-default table." .FormatWith(member, this)); temp = list.Find(x => x.TableName == null); if (temp != null) throw new DuplicateException( "Cannot add member '{0}' into this '{1}' because its name is already used in the default table." .FormatWith(member, this)); } _Members.Add(member); // To intercept re-entrant operation... member.Owner = this; }