/// <summary> /// See whether the AssociationEndIdentity otherEndId contains a "covering" for this /// i.e. for each AssociationPropertyIdentity in this._propertyIdentities see whether /// otherEndId._propertyIdentities contains a principal->dependent mapping which has /// at least the same principal DatabaseColumns (but possibly more) _and_ at least /// the same dependent DatabaseColumns (but possibly more). /// This allows for treating these AssociationEndIdentity's as identical for the purposes /// of Update Model even if a given C-side property has been mapped to more than 1 S-side property. /// </summary> internal bool IsCoveredBy(AssociationEndIdentity otherEndId) { foreach (var thisApi in _propertyIdentities) { var foundCoveringApi = false; if (null != otherEndId) { foreach (var otherApi in otherEndId._propertyIdentities) { if (thisApi.IsCoveredBy(otherApi)) { // have found an AssociationPropertyIdentity in otherEndId._propertyIdentities which covers thisApi foundCoveringApi = true; break; } } } if (false == foundCoveringApi) { // no covering AssociationPropertyIdentity was found for thisApi in // otherEndId._propertyIdentities return(false); } } // all AssociationPropertyIdentity's in this._propertyIdentities were covered by // AssociationPropertyIdentity's in other._propertyIdentities return(true); }
private void AddAssociationEndIdentity(AssociationEndIdentity assocEndIdentity) { if (_ends[0] == null) { _ends[0] = assocEndIdentity; } else { Debug.Assert(_ends[1] == null, "attempted to add more than two association ends!"); if (_ends[1] == null) { _ends[1] = assocEndIdentity; } } }
internal static AssociationIdentity CreateAssociationIdentity(AssociationSetMapping asm) { var sSideEntitySet = asm.StoreEntitySet.Target as StorageEntitySet; if (null == sSideEntitySet) { // a null sSideEntitySet indicates an unresolved AssociationSetMapping // we treat this as equivalent to the AssociationSet being unmapped return null; } var assocId = new AssociationIdentityForAssociationSetMapping(); assocId._assocTable = DatabaseObject.CreateFromEntitySet(sSideEntitySet); foreach (var endProp in asm.EndProperties()) { var assocEndId = new AssociationEndIdentity(endProp); assocId.AddAssociationEndIdentity(assocEndId); } return assocId; }
internal static AssociationIdentity CreateAssociationIdentity(AssociationSetMapping asm) { var sSideEntitySet = asm.StoreEntitySet.Target as StorageEntitySet; if (null == sSideEntitySet) { // a null sSideEntitySet indicates an unresolved AssociationSetMapping // we treat this as equivalent to the AssociationSet being unmapped return(null); } var assocId = new AssociationIdentityForAssociationSetMapping(); assocId._assocTable = DatabaseObject.CreateFromEntitySet(sSideEntitySet); foreach (var endProp in asm.EndProperties()) { var assocEndId = new AssociationEndIdentity(endProp); assocId.AddAssociationEndIdentity(assocEndId); } return(assocId); }
/// <summary> /// See whether the AssociationEndIdentity otherEndId contains a "covering" for this /// i.e. for each AssociationPropertyIdentity in this._propertyIdentities see whether /// otherEndId._propertyIdentities contains a principal->dependent mapping which has /// at least the same principal DatabaseColumns (but possibly more) _and_ at least /// the same dependent DatabaseColumns (but possibly more). /// This allows for treating these AssociationEndIdentity's as identical for the purposes /// of Update Model even if a given C-side property has been mapped to more than 1 S-side property. /// </summary> internal bool IsCoveredBy(AssociationEndIdentity otherEndId) { foreach (var thisApi in _propertyIdentities) { var foundCoveringApi = false; if (null != otherEndId) { foreach (var otherApi in otherEndId._propertyIdentities) { if (thisApi.IsCoveredBy(otherApi)) { // have found an AssociationPropertyIdentity in otherEndId._propertyIdentities which covers thisApi foundCoveringApi = true; break; } } } if (false == foundCoveringApi) { // no covering AssociationPropertyIdentity was found for thisApi in // otherEndId._propertyIdentities return false; } } // all AssociationPropertyIdentity's in this._propertyIdentities were covered by // AssociationPropertyIdentity's in other._propertyIdentities return true; }
private void AddAssociationEndIdentity(AssociationEndIdentity assocEndIdentity) { if (_ends[0] == null) { _ends[0] = assocEndIdentity; } else { Debug.Assert(_ends[1] == null, "attempted to add more than two association ends!"); if (_ends[1] == null) { _ends[1] = assocEndIdentity; } } }