예제 #1
0
        private void ApplyToStructuralProperty(IEdmModel model, StructuralPropertyConfiguration targetProperty)
        {
            Contract.Requires(model != null);
            Contract.Requires(targetProperty != null);

            var structuralType = model.FindDeclaredType(StructuralTypeName) as IEdmStructuredType;

            // the specified type is not a structural type (e.g. entity or complex)
            if (structuralType == null)
            {
                return;
            }

            var property = structuralType.FindProperty(targetProperty.Name);

            // the target property couldn't be found
            if (property == null)
            {
                return;
            }

            // aggregate all annotations for a given property
            var annotations = model.GetAnnotationValue <HashSet <InstanceAnnotation> >(property) ?? new HashSet <InstanceAnnotation>(InstanceAnnotationComparer.Instance);

            // update the qualified name as needed and add the annotation/term
            Annotation.QualifiedName = Invariant($"{Namespace}.{Name}");
            annotations.Add(Annotation);
            model.SetAnnotationValue(property, annotations);
            model.AddTerm(this, Annotation, "Property");
        }
예제 #2
0
        protected override void Apply(IEdmModel model)
        {
            Arg.NotNull(model, nameof(model));

            var entitySet = model.EntityContainer.FindEntitySet(EntitySetName);

            if (entitySet == null)
            {
                return;
            }

            // update casing just before the annotation is applied
            if (model.IsLowerCamelCaseEnabled())
            {
                Name      = Name.ToCamelCase();
                Namespace = Namespace.ToCamelCase();
            }

            // aggregate all annotations for a given entity set
            var annotations = model.GetAnnotationValue <HashSet <InstanceAnnotation> >(entitySet) ?? new HashSet <InstanceAnnotation>(InstanceAnnotationComparer.Instance);

            // update the qualified name as needed and add the annotation/term
            Annotation.QualifiedName = Invariant($"{Namespace}.{Name}");
            annotations.Add(Annotation);
            model.SetAnnotationValue(entitySet, annotations);
            model.AddTerm(this, Annotation, "EntitySet");
        }
예제 #3
0
        private void ApplyToStructuralType(IEdmModel model)
        {
            Contract.Requires(model != null);

            var entityType = model.FindDeclaredType(StructuralTypeName);

            if (entityType == null)
            {
                return;
            }

            // aggregate all annotations for a given entity type
            var annotations = model.GetAnnotationValue <HashSet <InstanceAnnotation> >(entityType) ?? new HashSet <InstanceAnnotation>(InstanceAnnotationComparer.Instance);

            // update the qualified name as needed and add the annotation/term
            Annotation.QualifiedName = Invariant($"{Namespace}.{Name}");
            annotations.Add(Annotation);
            model.SetAnnotationValue(entityType, annotations);
            model.AddTerm(this, Annotation, "EntityType ComplexType");
        }