コード例 #1
0
        /// <summary>
        /// Adds a new row to the association set.
        /// </summary>
        /// <returns>Instance of <see cref="AssociationSetDataRow "/> for the newly added row.</returns>
        public AssociationSetDataRow AddNewRow()
        {
            var row = new AssociationSetDataRow(this);

            this.Rows.Add(row);
            return(row);
        }
コード例 #2
0
        /// <summary>
        /// Copies entity container data.
        /// </summary>
        /// <param name="data">The entity container data to copy data to.</param>
        public void CopyTo(EntityContainerData data)
        {
            foreach (EntitySet entitySet in this.EntityContainer.EntitySets)
            {
                foreach (EntitySetDataRow sourceRow in this[entitySet].Rows)
                {
                    EntitySetDataRow destinationRow = data[entitySet].AddNewRowOfType(sourceRow.EntityType);
                    foreach (string path in sourceRow.PropertyPaths)
                    {
                        destinationRow[path] = sourceRow[path];
                    }
                }
            }

            foreach (AssociationSet associationSet in this.EntityContainer.AssociationSets)
            {
                foreach (AssociationSetDataRow sourceRow in this[associationSet].Rows)
                {
                    AssociationSetDataRow destinationRow = data[associationSet].AddNewRow();
                    foreach (string roleName in sourceRow.RoleNames)
                    {
                        destinationRow[roleName] = sourceRow[roleName];
                    }
                }
            }
        }
コード例 #3
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);
            }
        }
コード例 #4
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);
            }
        }
コード例 #5
0
 /// <summary>
 /// Adds a new row to the association set.
 /// </summary>
 /// <returns>Instance of <see cref="AssociationSetDataRow "/> for the newly added row.</returns>
 public AssociationSetDataRow AddNewRow()
 {
     var row = new AssociationSetDataRow(this);
     this.Rows.Add(row);
     return row;
 }