/// <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]; } } } }
/// <summary> /// Gets the related keys for the given roleName in an association(denoted by associationSetName), given this end's key. /// </summary> /// <param name="data">The EntityContainerData which contains AssociationSetData.</param> /// <param name="associationSetName">The name of the association set.</param> /// <param name="roleName">The roleName of the known end.</param> /// <param name="roleKey">The key for the role of the known end.</param> /// <returns>The Related keys of the other end.</returns> public static IEnumerable <EntityDataKey> GetRelatedKeys(this EntityContainerData data, string associationSetName, string roleName, EntityDataKey roleKey) { ExceptionUtilities.CheckArgumentNotNull(data, "data"); ExceptionUtilities.CheckStringArgumentIsNotNullOrEmpty(associationSetName, "associationSetName"); ExceptionUtilities.CheckStringArgumentIsNotNullOrEmpty(roleName, "roleName"); ExceptionUtilities.CheckArgumentNotNull(roleKey, "roleKey"); var associationSetData = data.GetAssociationSetData(associationSetName); string otherRoleName = associationSetData.AssociationSet.AssociationType.Ends.Where(e => e.RoleName != roleName).Single().RoleName; return(associationSetData.Rows.Where(r => roleKey.Equals(r.GetRoleKey(roleName))).Select(r => r.GetRoleKey(otherRoleName))); }
internal EntitySetData(EntityContainerData parent, EntitySet entitySet) { this.EntitySet = entitySet; this.Parent = parent; this.Rows = new List <EntitySetDataRow>(); var possibleEntityTypes = this.GetAllNonAbstractTypesOfKind(entitySet.EntityType).ToList(); if (possibleEntityTypes.Count == 1) { this.singleEntityType = possibleEntityTypes[0]; } }
/// <summary> /// Initializes a new instance of the <see cref="AssociationSetData"/> class. /// </summary> /// <param name="parent">The parent entity container data.</param> /// <param name="associationSet">The association set.</param> internal AssociationSetData(EntityContainerData parent, AssociationSet associationSet) { this.Parent = parent; this.AssociationSet = associationSet; this.Rows = new List <AssociationSetDataRow>(); }
/// <summary> /// Initializes a new instance of the <see cref="PropertyPathBuilder"/> class. /// </summary> /// <param name="entityContainerData">The entity container data.</param> public PropertyPathBuilder(EntityContainerData entityContainerData) { this.entityContainerData = entityContainerData; }