public static NavigationProperty LinkToSource(BidirectionalAssociation association) { return(new NavigationProperty { Cardinality = association.SourceMultiplicity , ClassType = association.Source , AssociationObject = association , PropertyName = association.SourcePropertyName , Summary = association.SourceSummary , Description = association.SourceDescription , CustomAttributes = association.SourceCustomAttributes , DisplayText = association.SourceDisplayText , IsAutoProperty = association.SourceAutoProperty , BackingFieldName = association.SourceAutoProperty ? null : association.SourceBackingFieldName , BackingFieldPropertyAccessMode = association.SourceAutoProperty ? null : association.SourcePropertyAccessMode.ToString() , ImplementNotify = association.SourceImplementNotify , FKPropertyName = association.SourceRole == EndpointRole.Principal ? association.FKPropertyName : null , PointsToSource = true }); }
protected override void WriteSourceDeleteBehavior(BidirectionalAssociation association, List <string> segments) { if (!association.Source.IsDependentType && !association.Target.IsDependentType && (association.TargetRole == EndpointRole.Principal || association.SourceRole == EndpointRole.Principal)) { DeleteAction deleteAction = association.SourceRole == EndpointRole.Principal ? association.SourceDeleteAction : association.TargetDeleteAction; switch (deleteAction) { case DeleteAction.None: segments.Add("OnDelete(DeleteBehavior.NoAction)"); break; case DeleteAction.Cascade: segments.Add("OnDelete(DeleteBehavior.Cascade)"); break; } } }