Exemplo n.º 1
0
        /// <summary>
        /// Imports data into the association set.
        /// </summary>
        /// <param name="data">The data to import. Each item in the data array corresponds to a row in the association set.</param>
        /// <example>
        /// data.ImportFrom(
        ///    new { Product = 1, Category = new {Id1 = 1; Id2 = 1 } },
        ///    new { Product = 2, Category = new {Id1 = 1; Id2 = 2 } })
        /// </example>
        public void ImportFrom(object[] data)
        {
            ExceptionUtilities.CheckArgumentNotNull(data, "data");

            var addedRows = new List<AssociationSetDataRow>();
            foreach (object item in data)
            {
                var row = new AssociationSetDataRow(this);
                row.ImportFrom(item);

                // Add new row only if Import succeeded.
                addedRows.Add(row);
            }

            // Add rows when all of them are successfully imported.
            foreach (AssociationSetDataRow row in addedRows)
            {
                this.Rows.Add(row);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Imports data into the association set.
        /// </summary>
        /// <param name="data">The data to import. Each item in the data array corresponds to a row in the association set.</param>
        /// <example>
        /// data.ImportFrom(
        ///    new { Product = 1, Category = new {Id1 = 1; Id2 = 1 } },
        ///    new { Product = 2, Category = new {Id1 = 1; Id2 = 2 } })
        /// </example>
        public void ImportFrom(object[] data)
        {
            ExceptionUtilities.CheckArgumentNotNull(data, "data");

            var addedRows = new List <AssociationSetDataRow>();

            foreach (object item in data)
            {
                var row = new AssociationSetDataRow(this);
                row.ImportFrom(item);

                // Add new row only if Import succeeded.
                addedRows.Add(row);
            }

            // Add rows when all of them are successfully imported.
            foreach (AssociationSetDataRow row in addedRows)
            {
                this.Rows.Add(row);
            }
        }