internal override bool ParseSingleElement(ICollection <XName> unprocessedElements, XElement elem) { if (elem.Name.LocalName == FunctionScalarProperty.ElementName) { var prop = new FunctionScalarProperty(this, elem); _scalarProperties.Add(prop); prop.Parse(unprocessedElements); } else if (elem.Name.LocalName == FunctionComplexProperty.ElementName) { var prop = new FunctionComplexProperty(this, elem); _complexProperties.Add(prop); prop.Parse(unprocessedElements); } else if (elem.Name.LocalName == FunctionAssociationEnd.ElementName) { var end = new FunctionAssociationEnd(this, elem); _ends.Add(end); end.Parse(unprocessedElements); } else if (elem.Name.LocalName == ResultBinding.ElementName) { var resultBinding = new ResultBinding(this, elem); _resultBindings.Add(resultBinding); resultBinding.Parse(unprocessedElements); } else { return(base.ParseSingleElement(unprocessedElements, elem)); } return(true); }
/// <summary> /// Normalize a refName where the refName is a child of a AssociationEnd /// </summary> /// <param name="fae"></param> /// <param name="parent"></param> /// <param name="refName"></param> /// <returns></returns> private static NormalizedName NormalizePropertyNameRelativeToFunctionAssociationEnd( FunctionAssociationEnd fae, EFElement parent, string refName) { NormalizedName nn = null; if (fae != null) { if (fae.To.Status == BindingStatus.Known) { nn = PropertyMappingNameNormalizer.NormalizeNameFromAssociationSetEnd(fae.To.Target, parent, refName); } } return(nn); }
/// <summary> /// Normalize a refName where the refName is a child of a AssociationEnd /// </summary> /// <param name="fae"></param> /// <param name="parent"></param> /// <param name="refName"></param> /// <returns></returns> private static NormalizedName NormalizePropertyNameRelativeToFunctionAssociationEnd( FunctionAssociationEnd fae, EFElement parent, string refName) { NormalizedName nn = null; if (fae != null) { if (fae.To.Status == BindingStatus.Known) { nn = ProperyMappingNameNormalizer.NormalizeNameFromAssociationSetEnd(fae.To.Target, parent, refName); } } return nn; }
internal void AddAssociationEnd(FunctionAssociationEnd end) { _ends.Add(end); }
internal static FunctionScalarProperty CreateFunctionScalarPropertyInAssociationEnd( ModificationFunction mf, Property entityProperty, NavigationProperty pointingNavProperty, Parameter parm, string version) { // in creating the function scalar property, we modify the AssociationEnd depending on the navigation property that is // pointing to the actual property. If we don't have this navigation property we can't do anything. Debug.Assert( pointingNavProperty != null, "We need the navigation property pointing to the property in order to create the mapping function scalar property"); if (pointingNavProperty == null) { throw new CannotLocateReferencedItemException(); } Debug.Assert(pointingNavProperty.Relationship.Target != null, "Where is the Association for this navigation property?"); if (pointingNavProperty.Relationship.Target == null) { throw new CannotLocateReferencedItemException(); } var assocSet = pointingNavProperty.Relationship.Target.AssociationSet; var navPropFromEnd = pointingNavProperty.FromRole.Target; var navPropToEnd = pointingNavProperty.ToRole.Target; Debug.Assert(null != navPropFromEnd, "Null FromRole for pointingNavProperty " + pointingNavProperty.ToPrettyString()); Debug.Assert(null != navPropToEnd, "Null ToRole for pointingNavProperty " + pointingNavProperty.ToPrettyString()); AssociationSetEnd assocSetFromEnd = null; AssociationSetEnd assocSetToEnd = null; // figure which end is which // Note: it is valid for the NavigationProperty to point to // an EntityType in the same inheritance hierarchy foreach (var end in assocSet.AssociationSetEnds()) { if (end.Role.Target == navPropFromEnd) { Debug.Assert( null == assocSetFromEnd, "pointingNavProperty From End " + navPropFromEnd.ToPrettyString() + " matches more than 1 AssociationSetEnd for AssociationSet " + assocSet.ToPrettyString()); assocSetFromEnd = end; } else if (end.Role.Target == navPropToEnd) { Debug.Assert( null == assocSetToEnd, "pointingNavProperty To End " + navPropToEnd.ToPrettyString() + " matches more than 1 AssociationSetEnd for AssociationSet " + assocSet.ToPrettyString()); assocSetToEnd = end; } } Debug.Assert(null != assocSetFromEnd, "Cannot find From end of AssociationSet " + assocSet.ToPrettyString()); Debug.Assert(null != assocSetToEnd, "Cannot find To end of AssociationSet " + assocSet.ToPrettyString()); // see if we already have this AssociationEnd FunctionAssociationEnd fae = null; foreach (var funcAssocEnd in mf.AssociationEnds()) { if (funcAssocEnd.AssociationSet.Target == assocSet && funcAssocEnd.From.Target == assocSetFromEnd && funcAssocEnd.To.Target == assocSetToEnd) { fae = funcAssocEnd; break; } } // create the association end if needed if (fae == null) { fae = new FunctionAssociationEnd(mf, null); fae.AssociationSet.SetRefName(assocSet); fae.From.SetRefName(assocSetFromEnd); fae.To.SetRefName(assocSetToEnd); mf.AddAssociationEnd(fae); XmlModelHelper.NormalizeAndResolve(fae); } Debug.Assert(fae != null, "Failed to create the AssocationEnd to house this ScalarProperty"); if (fae == null) { throw new ParentItemCreationFailureException(); } // create the SP inside this return CreateFunctionScalarPropertyCommon(fae, entityProperty, parm, version); }
internal override bool ParseSingleElement(ICollection<XName> unprocessedElements, XElement elem) { if (elem.Name.LocalName == FunctionScalarProperty.ElementName) { var prop = new FunctionScalarProperty(this, elem); _scalarProperties.Add(prop); prop.Parse(unprocessedElements); } else if (elem.Name.LocalName == FunctionComplexProperty.ElementName) { var prop = new FunctionComplexProperty(this, elem); _complexProperties.Add(prop); prop.Parse(unprocessedElements); } else if (elem.Name.LocalName == FunctionAssociationEnd.ElementName) { var end = new FunctionAssociationEnd(this, elem); _ends.Add(end); end.Parse(unprocessedElements); } else if (elem.Name.LocalName == ResultBinding.ElementName) { var resultBinding = new ResultBinding(this, elem); _resultBindings.Add(resultBinding); resultBinding.Parse(unprocessedElements); } else { return base.ParseSingleElement(unprocessedElements, elem); } return true; }
internal void AddAssociationEnd(FunctionAssociationEnd end) { _ends.Add(end); }