Exemplo n.º 1
0
 internal static void CheckResourceExists(bool resourceExists, string identifier)
 {
     if (!resourceExists)
     {
         throw DataServiceException.CreateResourceNotFound(identifier);
     }
 }
Exemplo n.º 2
0
 internal static void CheckNullDirectReference(object result, SegmentInfo segmentInfo)
 {
     if (segmentInfo.IsDirectReference && (result == null))
     {
         throw DataServiceException.CreateResourceNotFound(segmentInfo.Identifier);
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Checks query result.
        /// </summary>
        /// <param name="result">Query result to be checked.</param>
        /// <param name="segmentInfo">Segment details for the <paramref name="result"/>.</param>
        internal static void CheckQueryResult(object result, SegmentInfo segmentInfo)
        {
            // e.g. /Customers(4) - if there is a direct reference to an entity, it should not be null.
            // e.g. $value also must not be null, since you are dereferencing the values
            // Any other case, having null is fine
            if (segmentInfo.IsDirectReference && result == null)
            {
                throw DataServiceException.CreateResourceNotFound(segmentInfo.Identifier);
            }

            IEnumerable enumerable;

            if (segmentInfo.TargetKind == RequestTargetKind.OpenProperty &&
                WebUtil.IsElementIEnumerable(result, out enumerable))
            {
                throw DataServiceException.CreateSyntaxError(
                          Strings.InvalidUri_OpenPropertiesCannotBeCollection(segmentInfo.Identifier));
            }
        }