Ejemplo n.º 1
0
        /// <summary>
        /// Returns the unique member whose column name is given, or null if no such member can
        /// be found. If the collection contains several members with the same column name, even
        /// if they belong to different tables, an exception is thrown by default.
        /// </summary>
        /// <param name="column">The column name.</param>
        /// <param name="raise">True to raise an exception if several columns are found sharing
        /// the same name. If false then null is returned in that case.</param>
        /// <returns>The member found, or null.</returns>
        public ISchemaEntry FindEntry(string column, bool raise = true)
        {
            if (IsDisposed)
            {
                throw new ObjectDisposedException(this.ToString());
            }
            column = Core.SchemaEntry.ValidateColumn(column);

            var list = _Members.FindColumn(column);

            if (list.Count == 0)
            {
                return(null);
            }
            if (list.Count == 1)
            {
                return(list[0]);
            }

            list.Clear(); list = null;
            if (raise)
            {
                throw new DuplicateException(
                          "Column name '{0}' found in several entries: '{1}'.".FormatWith(column, list.Sketch()));
            }

            return(null);
        }