示例#1
0
        private void ProcessRelationationalIdentities(ref IClassMapper mapper, ref IClassMapper parent, PropertyInfo propertyInfo, IList <IReferenceMap> includedProperties)
        {
            if (includedProperties?.Count > 0)
            {
                if (mapper.Identity == parent.Identity)
                {
                    var parentIdentity = includedProperties[0].ParentIdentity;
                    mapper.SetIdentity(parentIdentity);
                    mapper.SetParentIdentity(parentIdentity);

                    parent.SetIdentity(parentIdentity);
                    parent.SetParentIdentity(parentIdentity);

                    SetReferencePropertiesParentIdentity(mapper, parentIdentity);
                    SetReferencePropertiesParentIdentity(parent, parentIdentity);
                }
                else
                {
                    var parentIdentity            = parent.Identity;
                    var childIdentityFromIncluded = includedProperties.FirstOrDefault(i => TablesAdded.Any(a => a.Identity == i.ParentIdentity) &&
                                                                                      i.ParentIdentity == parentIdentity && i.PropertyInfo == propertyInfo);

                    if (childIdentityFromIncluded != null)
                    {
                        mapper.SetIdentity(childIdentityFromIncluded.Identity);
                        SetReferencePropertiesParentIdentity(mapper, childIdentityFromIncluded.Identity);
                    }
                }
            }
        }