コード例 #1
0
        /// <summary>
        /// Gets the reader behavior for null property value on the specified property.
        /// </summary>
        /// <param name="model">The model containing the annotation.</param>
        /// <param name="property">The property to check.</param>
        /// <returns>The behavior to use when reading null value for this property.</returns>
        public static ODataNullValueBehaviorKind NullValueReadBehaviorKind(this IEdmModel model, IEdmProperty property)
        {
            ExceptionUtils.CheckArgumentNotNull(model, "model");
            ExceptionUtils.CheckArgumentNotNull(property, "property");

            ODataEdmPropertyAnnotation annotation = model.GetAnnotationValue <ODataEdmPropertyAnnotation>(property);

            return(annotation == null ? ODataNullValueBehaviorKind.Default : annotation.NullValueReadBehaviorKind);
        }
コード例 #2
0
ファイル: ODataUtils.cs プロジェクト: modulexcite/pash-1
        public static ODataNullValueBehaviorKind NullValueReadBehaviorKind(this IEdmModel model, IEdmProperty property)
        {
            ExceptionUtils.CheckArgumentNotNull <IEdmModel>(model, "model");
            ExceptionUtils.CheckArgumentNotNull <IEdmProperty>(property, "property");
            ODataEdmPropertyAnnotation annotationValue = model.GetAnnotationValue <ODataEdmPropertyAnnotation>(property);

            if (annotationValue != null)
            {
                return(annotationValue.NullValueReadBehaviorKind);
            }
            return(ODataNullValueBehaviorKind.Default);
        }
コード例 #3
0
ファイル: ODataUtils.cs プロジェクト: modulexcite/pash-1
        public static void SetNullValueReaderBehavior(this IEdmModel model, IEdmProperty property, ODataNullValueBehaviorKind nullValueReadBehaviorKind)
        {
            ExceptionUtils.CheckArgumentNotNull <IEdmModel>(model, "model");
            ExceptionUtils.CheckArgumentNotNull <IEdmProperty>(property, "property");
            ODataEdmPropertyAnnotation annotationValue = model.GetAnnotationValue <ODataEdmPropertyAnnotation>(property);

            if (annotationValue == null)
            {
                if (nullValueReadBehaviorKind != ODataNullValueBehaviorKind.Default)
                {
                    annotationValue = new ODataEdmPropertyAnnotation {
                        NullValueReadBehaviorKind = nullValueReadBehaviorKind
                    };
                    model.SetAnnotationValue <ODataEdmPropertyAnnotation>(property, annotationValue);
                }
            }
            else
            {
                annotationValue.NullValueReadBehaviorKind = nullValueReadBehaviorKind;
            }
        }