コード例 #1
0
		public TableRelation Add(TableBinding parentTable, IList<string> parentColumns, TableBinding childTable, IList<string> childColumns)
		{
			if (parentTable == null)
				throw ExceptionBuilder.ArgumentNull("parentTable");

			if (parentColumns == null)
				throw ExceptionBuilder.ArgumentNull("parentColumns");

			if (parentColumns.Count == 0)
				throw ExceptionBuilder.ArgumentArrayMustNotBeEmpty("parentColumns");

			if (childTable == null)
				throw ExceptionBuilder.ArgumentNull("childTable");

			if (childColumns == null)
				throw ExceptionBuilder.ArgumentNull("childColumns");

			if (childColumns.Count == 0)
				throw ExceptionBuilder.ArgumentArrayMustNotBeEmpty("childColumns");

			ColumnBinding[] parentColumnBindings = new ColumnBinding[parentColumns.Count];

			for (int i = 0; i < parentColumnBindings.Length; i++)
			{
				parentColumnBindings[i] = parentTable.GetColumn(parentColumns[i]);

				if (parentColumnBindings[i] == null)
					throw ExceptionBuilder.ParentColumnNotFound("parentColumns", parentTable, parentColumns[i]);
			}

			ColumnBinding[] childColumnBindings = new ColumnBinding[childColumns.Count];

			for (int i = 0; i < childColumnBindings.Length; i++)
			{
				childColumnBindings[i] = childTable.GetColumn(childColumns[i]);

				if (childColumnBindings[i] == null)
					throw ExceptionBuilder.ChildColumnNotFound("childColumns", childTable, childColumns[i]);
			}

			return Add(parentColumnBindings, childColumnBindings);
		}