Пример #1
0
 internal override bool IsMemberPendingGeneration(MetaDataMember keyMember)
 {
     if (this.IsNew && keyMember.IsDbGenerated)
     {
         return(true);
     }
     // look for any FK association that has this key member (should only be one)
     foreach (MetaAssociation assoc in type.Associations)
     {
         if (assoc.IsForeignKey)
         {
             int index = assoc.ThisKey.IndexOf(keyMember);
             if (index > -1)
             {
                 // we must have a reference to this other object to know if its side of
                 // the association is generated or not
                 object otherItem = null;
                 if (assoc.ThisMember.IsDeferred)
                 {
                     otherItem = assoc.ThisMember.DeferredValueAccessor.GetBoxedValue(this.current);
                 }
                 else
                 {
                     otherItem = assoc.ThisMember.StorageAccessor.GetBoxedValue(this.current);
                 }
                 if (otherItem != null)
                 {
                     if (assoc.IsMany)
                     {
                         // Can't be pending generation for a value that would have to be the same
                         // across many rows.
                         continue;
                     }
                     else
                     {
                         StandardTrackedObject trackedOther = (StandardTrackedObject)this.tracker.GetTrackedObject(otherItem);
                         if (trackedOther != null)
                         {
                             MetaDataMember otherMember = assoc.OtherKey[index];
                             return(trackedOther.IsMemberPendingGeneration(otherMember));
                         }
                     }
                 }
             }
         }
     }
     return(false);
 }