mirror of https://github.com/Squidex/squidex.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
1.2 KiB
38 lines
1.2 KiB
// ==========================================================================
|
|
// Squidex Headless CMS
|
|
// ==========================================================================
|
|
// Copyright (c) Squidex UG (haftungsbeschränkt)
|
|
// All rights reserved. Licensed under the MIT license.
|
|
// ==========================================================================
|
|
|
|
using System;
|
|
using System.Linq;
|
|
using Microsoft.OData.Edm;
|
|
using Microsoft.OData.UriParser;
|
|
|
|
namespace Squidex.Domain.Apps.Entities
|
|
{
|
|
public static class EdmModelExtensions
|
|
{
|
|
public static ODataUriParser ParseQuery(this IEdmModel model, string query)
|
|
{
|
|
if (!model.EntityContainer.EntitySets().Any())
|
|
{
|
|
return null;
|
|
}
|
|
|
|
query = query ?? string.Empty;
|
|
|
|
var path = model.EntityContainer.EntitySets().First().Path.Path.Split('.').Last();
|
|
|
|
if (query.StartsWith("?", StringComparison.Ordinal))
|
|
{
|
|
query = query.Substring(1);
|
|
}
|
|
|
|
var parser = new ODataUriParser(model, new Uri($"{path}?{query}", UriKind.Relative));
|
|
|
|
return parser;
|
|
}
|
|
}
|
|
}
|
|
|