Пример #1
0
        public bool IsValidIntersection(
            IntersectCandidate <EntityModel, EntityField, TypeModel, PropertyInfoField> intersectCandidate,
            out IntersectedFields <EntityModel, EntityField, TypeModel, PropertyInfoField> intersectedFields
            )
        {
            if (intersectCandidate.RightField.FieldDataType.IsGenericType &&
                intersectCandidate.RightField.FieldDataType.GetGenericTypeDefinition() == typeof(IEntityReference <>) &&
                intersectCandidate.RightField.FieldDataType.GetGenericArguments()[0] == intersectCandidate.LeftField.FieldDataType)
            {
                var referenceKeys = intersectCandidate.LeftField.SubFields
                                    .Where(q => q.IsEntityLocalField)
                                    .ToArray();

                if (referenceKeys.Length == 1)
                {
                    intersectedFields = BuildIntersectedFields(
                        intersectCandidate.LeftField,
                        intersectCandidate.LeftPath.Child(referenceKeys[0]),
                        intersectCandidate.RightPath
                        );
                    return(true);
                }
            }

            intersectedFields = null;
            return(false);
        }
Пример #2
0
 public virtual bool IsLeftFieldAlreadyPaired(IntersectCandidate <ViewIntersectionModel, ViewIntersectionField, EntityModel, EntityField> intersectCandidate)
 => _intersectedFields.Any(intersectedFields => ReferenceEquals(intersectedFields.LeftField, intersectCandidate.LeftField));