本文整理汇总了C#中Microsoft.AspNet.Http.HttpRequest.ODataProperties方法的典型用法代码示例。如果您正苦于以下问题:C# HttpRequest.ODataProperties方法的具体用法?C# HttpRequest.ODataProperties怎么用?C# HttpRequest.ODataProperties使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.AspNet.Http.HttpRequest
的用法示例。
在下文中一共展示了HttpRequest.ODataProperties方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ApplyQueryOptions
public virtual object ApplyQueryOptions(object value, HttpRequest request, ActionDescriptor descriptor)
{
var elementClrType = TypeHelper.GetImplementedIEnumerableType(value.GetType());
var model = request.ODataProperties().Model;
if (model == null)
{
throw Error.InvalidOperation(SRResources.QueryGetModelMustNotReturnNull);
}
var queryContext = new ODataQueryContext(
model,
elementClrType,
request.ODataProperties().Path);
var queryOptions = new ODataQueryOptions(queryContext, request);
var enumerable = value as IEnumerable;
if (enumerable == null)
{
// response is single entity.
return value;
}
// response is a collection.
var query = (value as IQueryable) ?? enumerable.AsQueryable();
return queryOptions.ApplyTo(query,
new ODataQuerySettings
{
HandleNullPropagation = HandleNullPropagationOption.True
});
}
示例2: IsRawValueRequest
internal static bool IsRawValueRequest(HttpRequest request)
{
ODataPath path = request.ODataProperties().Path;
return path != null && path.Segments.LastOrDefault() is ValuePathSegment;
}