private static DbRelatedEntityRef RelatedEntityRefFromAssociationSetEnd( EntityType constructedEntityType, DbNewInstanceExpression entityConstructor, AssociationSetEnd principalSetEnd, ReferentialConstraint fkConstraint) { EntityType elementType = (EntityType)TypeHelpers.GetEdmType <RefType>(fkConstraint.FromRole.TypeUsage).ElementType; IEnumerable <Tuple <string, DbExpression> > source = constructedEntityType.Properties.Select <EdmProperty, Tuple <EdmProperty, DbExpression> >((Func <EdmProperty, int, Tuple <EdmProperty, DbExpression> >)((p, idx) => Tuple.Create <EdmProperty, DbExpression>(p, entityConstructor.Arguments[idx]))).Join <Tuple <EdmProperty, DbExpression>, Tuple <EdmProperty, EdmProperty>, EdmProperty, Tuple <string, DbExpression> >(fkConstraint.FromProperties.Select <EdmProperty, Tuple <EdmProperty, EdmProperty> >((Func <EdmProperty, int, Tuple <EdmProperty, EdmProperty> >)((fp, idx) => Tuple.Create <EdmProperty, EdmProperty>(fp, fkConstraint.ToProperties[idx]))), (Func <Tuple <EdmProperty, DbExpression>, EdmProperty>)(pv => pv.Item1), (Func <Tuple <EdmProperty, EdmProperty>, EdmProperty>)(ft => ft.Item2), (Func <Tuple <EdmProperty, DbExpression>, Tuple <EdmProperty, EdmProperty>, Tuple <string, DbExpression> >)((pv, ft) => Tuple.Create <string, DbExpression>(ft.Item1.Name, pv.Item2))); IList <DbExpression> dbExpressionList; if (fkConstraint.FromProperties.Count == 1) { dbExpressionList = (IList <DbExpression>) new DbExpression[1] { source.Single <Tuple <string, DbExpression> >().Item2 }; } else { Dictionary <string, DbExpression> keyValueMap = source.ToDictionary <Tuple <string, DbExpression>, string, DbExpression>((Func <Tuple <string, DbExpression>, string>)(pav => pav.Item1), (Func <Tuple <string, DbExpression>, DbExpression>)(pav => pav.Item2), (IEqualityComparer <string>)StringComparer.Ordinal); dbExpressionList = (IList <DbExpression>)((IEnumerable <string>)elementType.KeyMemberNames).Select <string, DbExpression>((Func <string, DbExpression>)(memberName => keyValueMap[memberName])).ToList <DbExpression>(); } DbRefExpression dbRefExpression = principalSetEnd.EntitySet.CreateRef(elementType, (IEnumerable <DbExpression>)dbExpressionList); return(DbExpressionBuilder.CreateRelatedEntityRef(fkConstraint.ToRole, fkConstraint.FromRole, (DbExpression)dbRefExpression)); }
/// <summary> /// Gets the next entity type for association set end. /// </summary> /// <param name="associationSetEnd">The association set end.</param> /// <returns>Entity type.</returns> public EntityType GetNextEntityTypeForAssociationSetEnd(AssociationSetEnd associationSetEnd) { EntitySet entitySet = associationSetEnd.EntitySet; EntityType entityType = associationSetEnd.AssociationEnd.EntityType; Counter counter; List <EntityType> possibleTypes; if (this.entitySetsWithInheritance.TryGetValue(entitySet.Name, out possibleTypes)) { // Take into account associations between subtypes possibleTypes = possibleTypes.Where(t => t.IsKindOf(entityType)).ToList(); List <Counter> farthestFromTarget = new List <Counter>(); int maxCountRemainig = 0; this.FindFarthestFromTarget(entitySet.Name, ref maxCountRemainig, farthestFromTarget, possibleTypes.Select(t => t.Name)); if (farthestFromTarget.Count > 0) { counter = this.random.ChooseFrom(farthestFromTarget); entityType = counter.EntityType; } else { entityType = this.random.ChooseFrom(possibleTypes); } } return(entityType); }
// requires: entitySet must not be null // Yields all referenced association set ends in this mapping. private static IEnumerable <AssociationSetEnd> GetReferencedAssociationSetEnds(EntitySet entitySet, EntityType entityType, IEnumerable <StorageModificationFunctionParameterBinding> parameterBindings) { HashSet <AssociationSetEnd> ends = new HashSet <AssociationSetEnd>(); if (null != entitySet && null != entityType) { foreach (StorageModificationFunctionParameterBinding parameterBinding in parameterBindings) { AssociationSetEnd end = parameterBinding.MemberPath.AssociationSetEnd; if (null != end) { ends.Add(end); } } // If there is a referential constraint, it counts as an implicit mapping of // the association set foreach (AssociationSet assocationSet in MetadataHelper.GetAssociationsForEntitySet(entitySet)) { ReadOnlyMetadataCollection <ReferentialConstraint> constraints = assocationSet.ElementType.ReferentialConstraints; if (null != constraints) { foreach (ReferentialConstraint constraint in constraints) { if ((assocationSet.AssociationSetEnds[constraint.ToRole.Name].EntitySet == entitySet) && (constraint.ToRole.GetEntityType().IsAssignableFrom(entityType))) { ends.Add(assocationSet.AssociationSetEnds[constraint.FromRole.Name]); } } } } } return(ends); }
//Verifies that the Sets we got from visiting the tree( under AssociationType constructor) match the ones //defined in CSDL private void ValidateEntitySetsMappedForAssociationSetMapping(DbExpressionStructuralTypeEntitySetInfo setInfos) { AssociationSet associationSet = _setMapping.Set as AssociationSet; int i = 0; //While we should be able to find the EntitySets in all cases, since this is a user specified //query view, it is better to be defensive since we might have missed some path up the tree //while computing the sets if (setInfos.SetInfos.All(it => ((it.Value != null) && (it.Value is DbExpressionSimpleTypeEntitySetInfo))) && setInfos.SetInfos.Count() == 2) { foreach (DbExpressionSimpleTypeEntitySetInfo setInfo in setInfos.SetInfos.Select(it => it.Value)) { AssociationSetEnd setEnd = associationSet.AssociationSetEnds[i]; EntitySet declaredSet = setEnd.EntitySet; if (!declaredSet.Equals(setInfo.EntitySet)) { _errors.Add(new EdmSchemaError(System.Data.Entity.Strings.Mapping_EntitySetMismatchOnAssociationSetEnd_QueryView( setInfo.EntitySet.Name, declaredSet.Name, setEnd.Name, _setMapping.Set.Name), (int)StorageMappingErrorCode.MappingUnsupportedInitializationQueryView, EdmSchemaErrorSeverity.Error, _setMapping.EntityContainerMapping.SourceLocation, _setMapping.StartLineNumber, _setMapping.StartLinePosition)); } i++; } } }
private void AppendCreateForeignKeys(AssociationSet associationSet) { ReferentialConstraint referentialConstraint = associationSet.ElementType.ReferentialConstraints.Single <ReferentialConstraint>(); AssociationSetEnd associationSetEnd1 = associationSet.AssociationSetEnds[referentialConstraint.FromRole.Name]; AssociationSetEnd associationSetEnd2 = associationSet.AssociationSetEnds[referentialConstraint.ToRole.Name]; if (this.ignoredEntitySets.Contains(associationSetEnd1.EntitySet) || this.ignoredEntitySets.Contains(associationSetEnd2.EntitySet)) { this.AppendSql("-- Ignoring association set with participating entity set with defining query: "); this.AppendIdentifierEscapeNewLine(associationSet.Name); } else { this.AppendSql("alter table "); this.AppendIdentifier(associationSetEnd2.EntitySet); this.AppendSql(" add constraint "); this.AppendIdentifier(associationSet.Name); this.AppendSql(" foreign key ("); this.AppendIdentifiers((IEnumerable <EdmProperty>)referentialConstraint.ToProperties); this.AppendSql(") references "); this.AppendIdentifier(associationSetEnd1.EntitySet); this.AppendSql("("); this.AppendIdentifiers((IEnumerable <EdmProperty>)referentialConstraint.FromProperties); this.AppendSql(")"); if (associationSetEnd1.CorrespondingAssociationEndMember.DeleteBehavior == OperationAction.Cascade) { this.AppendSql(" on delete cascade"); } this.AppendSql(";\n\n"); } this.AppendNewLine(); }
/// <summary> /// Sets the capacity range selector for the specified association set and end. /// </summary> /// <param name="associationSet">The association set.</param> /// <param name="associationSetEnd">The association set end.</param> /// <param name="selector">The capacity range selector.</param> public void SetCapacityRangeSelector(AssociationSet associationSet, AssociationSetEnd associationSetEnd, Func <CapacityRange> selector) { ExceptionUtilities.CheckArgumentNotNull(associationSet, "associationSet"); ExceptionUtilities.CheckArgumentNotNull(associationSetEnd, "associationSetEnd"); this.SetCapacityRangeSelector(associationSet.Name, associationSetEnd.AssociationEnd.RoleName, selector); }
private void WriteAssociationSetEndElement(AssociationSetEnd end) { _writer.WriteStartElement(XmlConstants.End); _writer.WriteAttributeString(XmlConstants.Role, end.Name); _writer.WriteAttributeString(XmlConstants.EntitySet, end.EntitySet.Name); _writer.WriteEndElement(); }
/// <summary> /// Determine if the end is 'contained' in the source entity via a referential integrity constraint (e.g., /// in a relationship from OrderDetail to Order where OrderDetail has the OrderId property, the association set end /// is contained in the order detail entity) /// </summary> private static bool IsContained(AssociationSetEnd end, out ReferentialConstraint constraint) { CheckArgumentNull(end, "end"); AssociationEndMember endMember = end.CorrespondingAssociationEndMember; AssociationType associationType = (AssociationType)endMember.DeclaringType; constraint = null; bool result = false; if (null != associationType.ReferentialConstraints) { foreach (ReferentialConstraint candidate in associationType.ReferentialConstraints) { if (candidate.FromRole.Name == endMember.Name) { constraint = candidate; result = true; break; } } } return(result); }
private static IEnumerable <AssociationSetEnd> GetReferencedAssociationSetEnds( EntitySet entitySet, EntityType entityType, IEnumerable <ModificationFunctionParameterBinding> parameterBindings) { HashSet <AssociationSetEnd> associationSetEndSet = new HashSet <AssociationSetEnd>(); if (entitySet != null && entityType != null) { foreach (ModificationFunctionParameterBinding parameterBinding in parameterBindings) { AssociationSetEnd associationSetEnd = parameterBinding.MemberPath.AssociationSetEnd; if (associationSetEnd != null) { associationSetEndSet.Add(associationSetEnd); } } foreach (AssociationSet associationsForEntity in MetadataHelper.GetAssociationsForEntitySet((EntitySetBase)entitySet)) { ReadOnlyMetadataCollection <ReferentialConstraint> referentialConstraints = associationsForEntity.ElementType.ReferentialConstraints; if (referentialConstraints != null) { foreach (ReferentialConstraint referentialConstraint in referentialConstraints) { if (associationsForEntity.AssociationSetEnds[referentialConstraint.ToRole.Name].EntitySet == entitySet && referentialConstraint.ToRole.GetEntityType().IsAssignableFrom((EdmType)entityType)) { associationSetEndSet.Add(associationsForEntity.AssociationSetEnds[referentialConstraint.FromRole.Name]); } } } } } return((IEnumerable <AssociationSetEnd>)associationSetEndSet); }
private void WriteAssociationSetMappingElement(XmlWriter writer, CollapsedEntityAssociationSet collapsedAssociationSet) { if (!collapsedAssociationSet.ModelAssociationSet.ElementType.IsForeignKey) { writer.WriteStartElement(StorageMslConstructs.AssociationSetMappingElement, _xmlNamespace); writer.WriteAttributeString(StorageMslConstructs.AssociationSetMappingNameAttribute, collapsedAssociationSet.ModelAssociationSet.Name); writer.WriteAttributeString(StorageMslConstructs.AssociationSetMappingTypeNameAttribute, collapsedAssociationSet.ModelAssociationSet.ElementType.FullName); writer.WriteAttributeString(StorageMslConstructs.AssociationSetMappingStoreEntitySetAttribute, collapsedAssociationSet.EntitySet.Name); for (int i = 0; i < collapsedAssociationSet.AssociationSets.Count; i++) { AssociationSetEnd storeEnd; RelationshipMultiplicity multiplicity; OperationAction deleteBehavior; collapsedAssociationSet.GetStoreAssociationSetEnd(i, out storeEnd, out multiplicity, out deleteBehavior); AssociationSetEnd modelEnd = _lookups.StoreAssociationSetEndToModelAssociationSetEnd[storeEnd]; WriteEndPropertyElement(writer, storeEnd, modelEnd); } // don't need condition element writer.WriteEndElement(); } }
private void WriteAssociationSetMappingElement(XmlWriter writer, AssociationSet store, AssociationSet model) { if (!model.ElementType.IsForeignKey) { writer.WriteStartElement(StorageMslConstructs.AssociationSetMappingElement, _xmlNamespace); writer.WriteAttributeString(StorageMslConstructs.AssociationSetMappingNameAttribute, model.Name); writer.WriteAttributeString(StorageMslConstructs.AssociationSetMappingTypeNameAttribute, model.ElementType.FullName); // all column names must be the primary key of the // end, but as columns in the Fk table. AssociationSetEnd foreignKeyTableEnd = GetAssociationSetEndForForeignKeyTable(store); writer.WriteAttributeString(StorageMslConstructs.AssociationSetMappingStoreEntitySetAttribute, foreignKeyTableEnd.EntitySet.Name); foreach (AssociationSetEnd storeEnd in store.AssociationSetEnds) { AssociationSetEnd modelEnd = _lookups.StoreAssociationSetEndToModelAssociationSetEnd[storeEnd]; WriteEndPropertyElement(writer, storeEnd, modelEnd); } ReferentialConstraint constraint = GetReferentialConstraint(store); foreach (EdmProperty fkColumn in constraint.ToProperties) { if (fkColumn.Nullable) { WriteConditionElement(writer, fkColumn); } } writer.WriteEndElement(); } }
private void ValidateEntitySetsMappedForAssociationSetMapping( ViewValidator.DbExpressionStructuralTypeEntitySetInfo setInfos) { AssociationSet set = this._setMapping.Set as AssociationSet; int index = 0; if (!setInfos.SetInfos.All <KeyValuePair <string, ViewValidator.DbExpressionEntitySetInfo> >((Func <KeyValuePair <string, ViewValidator.DbExpressionEntitySetInfo>, bool>)(it => { if (it.Value != null) { return(it.Value is ViewValidator.DbExpressionSimpleTypeEntitySetInfo); } return(false); })) || setInfos.SetInfos.Count <KeyValuePair <string, ViewValidator.DbExpressionEntitySetInfo> >() != 2) { return; } foreach (ViewValidator.DbExpressionSimpleTypeEntitySetInfo typeEntitySetInfo in setInfos.SetInfos.Select <KeyValuePair <string, ViewValidator.DbExpressionEntitySetInfo>, ViewValidator.DbExpressionEntitySetInfo>((Func <KeyValuePair <string, ViewValidator.DbExpressionEntitySetInfo>, ViewValidator.DbExpressionEntitySetInfo>)(it => it.Value))) { AssociationSetEnd associationSetEnd = set.AssociationSetEnds[index]; EntitySet entitySet = associationSetEnd.EntitySet; if (!entitySet.Equals((object)typeEntitySetInfo.EntitySet)) { this._errors.Add(new EdmSchemaError(Strings.Mapping_EntitySetMismatchOnAssociationSetEnd_QueryView((object)typeEntitySetInfo.EntitySet.Name, (object)entitySet.Name, (object)associationSetEnd.Name, (object)this._setMapping.Set.Name), 2074, EdmSchemaErrorSeverity.Error, this._setMapping.EntityContainerMapping.SourceLocation, this._setMapping.StartLineNumber, this._setMapping.StartLinePosition)); } ++index; } }
public AssociationSetEndDetails( AssociationSetEnd associationSetEnd, RelationshipMultiplicity multiplicity, OperationAction deleteBehavior) { AssociationSetEnd = associationSetEnd; Multiplicity = multiplicity; DeleteBehavior = deleteBehavior; }
internal static EntityDataSourceReferenceGroup Create(Type entityType, AssociationSetEnd end) { EntityDataSourceUtil.CheckArgumentNull(entityType, "entityType"); Type groupType = typeof(EntityDataSourceReferenceGroup <>).MakeGenericType(entityType); return((EntityDataSourceReferenceGroup)Activator.CreateInstance(groupType, new object[] { end })); }
internal AssociationSetEndMappingBuilder(AssociationSetEnd setEnd, StorageEntityType storageEntityType) { Debug.Assert(setEnd != null, "setEnd should not be null"); Debug.Assert(storageEntityType != null, "storageEntityType should not be null"); _setEnd = setEnd; _storageEntityType = storageEntityType; }
private static void InitializeForeignKeyMaps(HashSet <EntityContainer> containers, HashSet <EntitySet> tables, out KeyToListMap <EntitySetBase, ReferentialConstraint> sourceMap, out KeyToListMap <EntitySetBase, ReferentialConstraint> targetMap) { sourceMap = new KeyToListMap <EntitySetBase, ReferentialConstraint>(EqualityComparer <EntitySetBase> .Default); targetMap = new KeyToListMap <EntitySetBase, ReferentialConstraint>(EqualityComparer <EntitySetBase> .Default); // Retrieve relationship ends from each container to populate edges in dependency // graph foreach (EntityContainer container in containers) { foreach (EntitySetBase extent in container.BaseEntitySets) { AssociationSet associationSet = extent as AssociationSet; if (null != associationSet) { AssociationSetEnd source = null; AssociationSetEnd target = null; var ends = associationSet.AssociationSetEnds; if (2 == ends.Count) { // source is equivalent to the "to" end of relationship, target is "from" AssociationType associationType = associationSet.ElementType; bool constraintFound = false; ReferentialConstraint fkConstraint = null; foreach (ReferentialConstraint constraint in associationType.ReferentialConstraints) { if (constraintFound) { Debug.Fail("relationship set should have at most one constraint"); } else { constraintFound = true; } source = associationSet.AssociationSetEnds[constraint.ToRole.Name]; target = associationSet.AssociationSetEnds[constraint.FromRole.Name]; fkConstraint = constraint; } Debug.Assert(constraintFound && null != target && null != source, "relationship set must have at least one constraint"); // only understand binary (foreign key) relationships between entity sets if (null != target && null != source) { if (tables.Contains(target.EntitySet) && tables.Contains(source.EntitySet)) { // Remember metadata sourceMap.Add(source.EntitySet, fkConstraint); targetMap.Add(target.EntitySet, fkConstraint); } } } } } } }
// requires: end is given // effects: returns the opposite end in the association internal static AssociationSetEnd GetOppositeEnd(AssociationSetEnd end) { DebugCheck.NotNull(end); // there must be exactly one ("Single") other end that isn't ("Filter") this end var otherEnd = end.ParentAssociationSet.AssociationSetEnds.Where( e => !e.EdmEquals(end)).Single(); return(otherEnd); }
private XElement GenerateAssociationSetEnd(XNamespace xmlNamespace, AssociationSetEnd setEnd) { return(new XElement( xmlNamespace + "End", new XAttribute("Role", setEnd.AssociationEnd.RoleName), new XAttribute("EntitySet", setEnd.EntitySet.Name), this.GenerateDocumentation(xmlNamespace, setEnd), this.GenerateAnnotations(xmlNamespace, setEnd))); }
private CreateEndScalarPropertyCommand( AssociationSetMapping associationSetMapping, AssociationSetEnd associationSetEnd, Property entityProperty, Property tableColumn, bool enforceConstraints) { Initialize(entityProperty, tableColumn, enforceConstraints); CommandValidation.ValidateAssociationSetMapping(associationSetMapping); CommandValidation.ValidateAssociationSetEnd(associationSetEnd); _associationSetMapping = associationSetMapping; _associationSetEnd = associationSetEnd; }
/// <summary> /// Initializes a new instance of the <see cref="PropertyConstraint"/> class. /// </summary> /// <param name="associationSet">The association set.</param> /// <param name="ordinal">The ordinal of the constraint in the <see cref="ReferentialConstraint"/> for the association set.</param> public PropertyConstraint(AssociationSet associationSet, int ordinal) { this.AssociationSet = associationSet; this.ordinal = ordinal; AssociationSetEnd principalEnd = associationSet.Ends.Where(e => e.AssociationEnd == associationSet.AssociationType.ReferentialConstraint.PrincipalAssociationEnd).Single(); this.PrincipalEntitySet = principalEnd.EntitySet; this.DependentEntitySet = associationSet.GetOtherEnd(principalEnd).EntitySet; }
private AssociationSetEnd ParseAssociationSetEnd(XElement associationSetEndElement) { string roleName = associationSetEndElement.GetRequiredAttributeValue("Role"); var entitySetName = associationSetEndElement.GetRequiredAttributeValue("EntitySet"); var associationSetEnd = new AssociationSetEnd(roleName, entitySetName); this.ParseAnnotations(associationSetEnd, associationSetEndElement); return(associationSetEnd); }
// requires: toEnd and type are given // effects: determines whether the given association end can be referenced by an entity of the given type internal static bool IsAssociationValidForEntityType(AssociationSetEnd toEnd, EntityType type) { DebugCheck.NotNull(toEnd); DebugCheck.NotNull(type); // get the opposite end which includes the relevant type information var fromEnd = GetOppositeEnd(toEnd); var fromType = GetEntityTypeForEnd(fromEnd.CorrespondingAssociationEndMember); return(fromType.IsAssignableFrom(type)); }
private void GetFromAssociationSetEnd(AssociationSet definingSet, AssociationSet multiplicitySet, out AssociationSetEnd associationSetEnd, out RelationshipMultiplicity multiplicity, out OperationAction deleteBehavior) { // for a situation like this (CD is CascadeDelete) // // -------- CD -------- CD -------- // | A |1 <- 1| AtoB |* <- 1| B | // | |-------| |-------| | // | | | | | | // -------- -------- -------- // // You get // -------- CD -------- // | A |* <- 1| B | // | |-------| | // | | | | // -------- -------- // // Notice that the of the new "link table association" muliplicities are opposite of what comming into the original link table // this seems counter intuitive at first, but makes sense when you think all the way through it // // CascadeDelete Behavior (we can assume the runtime will always delete cascade // to the link table from the outside tables (it actually doesn't, but that is a bug)) // Store Effective // A -> AToB <- B None // A <- AToB <- B <- // A -> AToB -> B -> // A <- AToB -> B None // A <- AToB B <- // A AToB -> B -> // A -> AToB B None // A AToB <- B None // // Other CascadeDelete rules // 1. Can't have a delete from a Many multiplicity end // 2. Can't have a delete on both ends // associationSetEnd = GetAssociationSetEnd(definingSet, true); AssociationSetEnd multiplicityAssociationSetEnd = GetAssociationSetEnd(multiplicitySet, false); multiplicity = multiplicityAssociationSetEnd.CorrespondingAssociationEndMember.RelationshipMultiplicity; deleteBehavior = OperationAction.None; if (multiplicity != RelationshipMultiplicity.Many) { OperationAction otherEndBehavior = GetAssociationSetEnd(definingSet, false).CorrespondingAssociationEndMember.DeleteBehavior; if (otherEndBehavior == OperationAction.None) { // Since the other end does not have an operation // that means that only one end could possibly have an operation, that is good // so set it the operation deleteBehavior = multiplicityAssociationSetEnd.CorrespondingAssociationEndMember.DeleteBehavior; } } }
/// <summary> /// Initializes a new instance of the <see cref="RelationshipGroupEnd"/> class. /// </summary> /// <param name="associationSet">The association set.</param> /// <param name="associationSetEnd">The association set end.</param> public RelationshipGroupEnd(AssociationSet associationSet, AssociationSetEnd associationSetEnd) { this.EntitySet = associationSetEnd.EntitySet; this.EntityType = associationSetEnd.AssociationEnd.EntityType; this.Multiplicity = associationSet.GetOtherEnd(associationSetEnd).AssociationEnd.Multiplicity; this.associationSetEnds = new List <KeyValuePair <AssociationSet, AssociationSetEnd> >(); this.associationSetEnds.Add(new KeyValuePair <AssociationSet, AssociationSetEnd>(associationSet, associationSetEnd)); this.Candidates = new List <RelationshipCandidate>(); this.CapacitySelector = CapacityRangeSelector.GetDefaultCapacityRangeSelector(this.Multiplicity); }
private void WriteEndPropertyElement(XmlWriter writer, AssociationSetEnd store, AssociationSetEnd model) { writer.WriteStartElement(StorageMslConstructs.EndPropertyMappingElement, _xmlNamespace); writer.WriteAttributeString(StorageMslConstructs.EndPropertyMappingNameAttribute, model.Name); foreach (EdmProperty storeKeyMember in store.EntitySet.ElementType.KeyMembers) { EdmProperty modelKeyMember = _lookups.StoreEdmPropertyToModelEdmProperty[storeKeyMember]; EdmProperty storeFkTableMember = GetAssociatedFkColumn(store, storeKeyMember); WriteScalarPropertyElement(writer, storeFkTableMember, modelKeyMember); } writer.WriteEndElement(); }
/// <summary> /// Initializes a new ModificationFunctionMemberPath instance. /// </summary> /// <param name="members">Gets the members in the path from the leaf (the member being bound) /// to the root of the structure.</param> /// <param name="associationSet">Gets the association set to which we are navigating /// via this member. If the value is null, this is not a navigation member path.</param> public ModificationFunctionMemberPath( IEnumerable <EdmMember> members, AssociationSet associationSet) { Check.NotNull <IEnumerable <EdmMember> >(members, nameof(members)); this._members = new ReadOnlyCollection <EdmMember>((IList <EdmMember>) new List <EdmMember>(members)); if (associationSet == null) { return; } this._associationSetEnd = associationSet.AssociationSetEnds[this.Members[1].Name]; }
/// <summary> /// Initializes a new instance of the <see cref="RelationshipSide"/> class. /// </summary> /// <param name="associationSetEnd">The <see cref="FromAssociationSetEnd"/> which describes this side of the relationship.</param> /// <param name="relationshipType">The parent <see cref="RelationshipType"/>.</param> internal RelationshipSide(AssociationSetEnd associationSetEnd, RelationshipType relationshipType) { this.FromAssociationSetEnd = associationSetEnd; this.FromAssociationEnd = associationSetEnd.AssociationEnd; this.FromEntitySet = associationSetEnd.EntitySet; this.FromEntityType = this.FromAssociationEnd.EntityType; this.FromDeleteBehavior = this.FromAssociationEnd.DeleteBehavior; this.FromMultiplicity = this.FromAssociationEnd.Multiplicity; this.FromNavigationProperty = this.FromAssociationEnd.FromNavigationProperty(); this.FromRoleName = this.FromAssociationEnd.RoleName; this.RelationshipType = relationshipType; }
protected override void Visit(AssociationSetEnd associationSetEnd) { int instanceIndex; if (!this.AddObjectToSeenListAndHashBuilder((object)associationSetEnd, out instanceIndex)) { return; } this.AddObjectStartDumpToHashBuilder((object)associationSetEnd, instanceIndex); this.AddObjectContentToHashBuilder((object)associationSetEnd.Identity); base.Visit(associationSetEnd); this.AddObjectEndDumpToHashBuilder(); }
// effects: Creates a boolean variable representing the right extent or association end internal RoleBoolean CreateRoleBoolean() { if (RightExtent is AssociationSet) { Set <AssociationEndMember> ends = GetEndsForTablePrimaryKey(); if (ends.Count == 1) { AssociationSetEnd setEnd = ((AssociationSet)RightExtent).AssociationSetEnds[ends.First().Name]; return(new RoleBoolean(setEnd)); } } return(new RoleBoolean(RightExtent)); }
internal override void ToCompactString(StringBuilder builder) { AssociationSetEnd end = m_metadataItem as AssociationSetEnd; if (end != null) { builder.Append("InEnd:" + end.ParentAssociationSet + "_" + end.Name); } else { builder.Append("InSet:" + m_metadataItem.ToString()); } }
/// <summary> /// Adds the given end to the collection of ends /// </summary> /// <param name="associationSetEnd"></param> internal void AddAssociationSetEnd(AssociationSetEnd associationSetEnd) { AssociationSetEnds.Source.Add(associationSetEnd); }
/// <summary> /// Populate ResourceAssociationSetEnd from the AssociationSetEnd instance. /// </summary> /// <param name="setEnd">Instance of AssociationSetEnd.</param> /// <param name="resourceSet">ResourceSet to which the type referred by the end belongs to.</param> /// <param name="resourceType">ResourceType referred by the end.</param> /// <param name="resourceProperty">ResourceProperty that takes part in the association.</param> /// <returns>An instance of ResourceAssociationSetEnd.</returns> private static ResourceAssociationSetEnd PopulateResourceAssociationSetEnd(AssociationSetEnd setEnd, ResourceSet resourceSet, ResourceType resourceType, ResourceProperty resourceProperty) { ResourceAssociationSetEnd resourceAssociationSetEnd = new ResourceAssociationSetEnd(resourceSet, resourceType, resourceProperty); #if !EF6Provider resourceAssociationSetEnd.Name = setEnd.Name; // Populate Annotations ObjectContextServiceProvider.PopulateAnnotations(setEnd.MetadataProperties, resourceAssociationSetEnd.AddCustomAnnotation); #endif return resourceAssociationSetEnd; }