Пример #1
0
 public IEntityTypeBuilder WithStructuralProperty(IStructuralProperty property)
 {
     this.ThrowIfAlreadyBuilt();
     this.ThrowIfDuplicatePropertyName(property.EdmPropertyName);
     this.properties.Add(property.EdmPropertyName, property);
     return(this);
 }
Пример #2
0
 public ResourceSignatureTypeInitializer(
     ISignatureEntitySetInitializer signatureSetInitializer,
     IResourceService resourceService,
     IStructuralProperty quantityTypeProperty)
 {
     this.signatureSetInitializer = signatureSetInitializer;
     this.resourceService         = resourceService;
     this.quantityTypeProperty    = quantityTypeProperty;
 }
Пример #3
0
        public bool TryCreate(IProperty property, string edmPropertyName, out IStructuralProperty structuralProperty)
        {
            IDataType dataType;

            if (!this.TryGetDataType(property, out dataType))
            {
                structuralProperty = null;
                return(false);
            }

            structuralProperty = new CostSharpStructuralProperty(property, edmPropertyName, dataType);
            return(true);
        }
Пример #4
0
        public bool TryCreate(IProperty property, out IStructuralProperty structuralProperty)
        {
            IDataType dataType;

            if (!this.TryGetDataType(property, out dataType))
            {
                structuralProperty = null;
                return(false);
            }

            structuralProperty = new CostSharpStructuralProperty(property, this.modelItemNamingService.GetSafeEdmPropertyName(property), dataType);
            return(true);
        }
Пример #5
0
        private static bool TryGetPropertyDependency(IStructuralProperty property, ODataEntityDto oDataEntity, out IDependency dependency)
        {
            object propertyValue;

            if (oDataEntity.TryGetPropertyValue(property, out propertyValue))
            {
                dependency = new PropertyDependency(property, propertyValue);
                return(true);
            }

            dependency = null;
            return(false);
        }
Пример #6
0
        public static bool TryGetPropertyValue(this ODataEntityDto oDataEntity, IStructuralProperty property, out object value)
        {
            var targetProperty = oDataEntity.Entry.Properties.FirstOrDefault(p => p.Name == property.EdmPropertyName);

            if (targetProperty != null)
            {
                var odataPropertyValue = targetProperty.Value;
                value = property.Deserialize(odataPropertyValue);
                return(true);
            }

            value = null;
            return(false);
        }
Пример #7
0
        protected override bool TryHandleStructuralProperty(
            IEntity targetEntity,
            ODataEntityDto oDataEntity,
            IStructuralProperty structuralProperty)
        {
            var structuralEntityProperty = structuralProperty as IStructuralEntityProperty;

            if (structuralEntityProperty != null && structuralEntityProperty.IsReadOnly(targetEntity))
            {
                // According to OData v4 Part 1 (Protocol), section 11.4.3 and 11.4.4, properties which are non-updatable should be ignored
                // during Update and Upsert. Hence, we return true here, claiming the property was handled correctly.
                return(true);
            }

            return(base.TryHandleStructuralProperty(targetEntity, oDataEntity, structuralProperty));
        }
Пример #8
0
        public bool TryCreate <T>(
            string edmPropertyName,
            Func <IEntity, T> valueGetter,
            Action <IEntity, T> valueSetter,
            bool canBeNull,
            out IStructuralProperty structuralProperty)
        {
            IValueBasedDataType dataType;

            if (!this.TryGetValueBasedDataType <T>(out dataType))
            {
                structuralProperty = null;
                return(false);
            }

            structuralProperty = new StructuralProperty <T>(edmPropertyName, dataType, valueGetter, valueSetter, canBeNull);
            return(true);
        }
Пример #9
0
        protected virtual bool TryHandleStructuralProperty(
            IEntity targetEntity,
            ODataEntityDto oDataEntity,
            IStructuralProperty structuralProperty)
        {
            var structuralEntityProperty = structuralProperty as IStructuralEntityProperty;

            if (structuralEntityProperty == null)
            {
                return(false);
            }

            if (!this.structuralPropertyBinder.TrySetOnEntity(targetEntity, oDataEntity, structuralEntityProperty))
            {
                return(false);
            }

            return(true);
        }
Пример #10
0
        public IBindableModelBuilder WithOptionalDependency(INavigatableElementBuilder navigatableElementBuilder, IStructuralProperty dependency)
        {
            var declaration = new DependencyDeclaration(dependency, true);

            this.dependencies.Add(new KeyValuePair <INavigatableElementBuilder, DependencyDeclaration>(navigatableElementBuilder, declaration));
            return(this);
        }
Пример #11
0
 public bool TryGetKeyProperty(string propertyName, out IStructuralProperty keyProperty)
 {
     return(this.keyProperties.TryGetValue(propertyName, out keyProperty));
 }
Пример #12
0
 public PropertyDependency(IStructuralProperty property, object value)
 {
     this.property = property;
     this.Value    = value;
 }