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.
87 lines
2.4 KiB
87 lines
2.4 KiB
// ==========================================================================
|
|
// Squidex Headless CMS
|
|
// ==========================================================================
|
|
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|
// All rights reserved. Licensed under the MIT license.
|
|
// ==========================================================================
|
|
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Squidex.Infrastructure;
|
|
using Squidex.Infrastructure.Json.Objects;
|
|
using Squidex.Infrastructure.Queries;
|
|
|
|
namespace Squidex.Domain.Apps.Entities
|
|
{
|
|
public sealed class Q : Cloneable<Q>
|
|
{
|
|
public static readonly Q Empty = new Q();
|
|
|
|
public IReadOnlyList<DomainId> Ids { get; private set; }
|
|
|
|
public DomainId? Reference { get; private set; }
|
|
|
|
public string? ODataQuery { get; private set; }
|
|
|
|
public string? JsonQuery { get; private set; }
|
|
|
|
public Query<IJsonValue>? ParsedJsonQuery { get; private set; }
|
|
|
|
public ClrQuery? Query { get; private set; }
|
|
|
|
public Q WithQuery(ClrQuery? query)
|
|
{
|
|
return Clone(clone => clone.Query = query);
|
|
}
|
|
|
|
public Q WithODataQuery(string? odataQuery)
|
|
{
|
|
return Clone(clone => clone.ODataQuery = odataQuery);
|
|
}
|
|
|
|
public Q WithJsonQuery(string? jsonQuery)
|
|
{
|
|
return Clone(clone => clone.JsonQuery = jsonQuery);
|
|
}
|
|
|
|
public Q WithJsonQuery(Query<IJsonValue>? jsonQuery)
|
|
{
|
|
return Clone(clone => clone.ParsedJsonQuery = jsonQuery);
|
|
}
|
|
|
|
public Q WithIds(params DomainId[] ids)
|
|
{
|
|
return Clone(clone => clone.Ids = ids.ToList());
|
|
}
|
|
|
|
public Q WithReference(DomainId? reference)
|
|
{
|
|
return Clone(clone => clone.Reference = reference);
|
|
}
|
|
|
|
public Q WithIds(IEnumerable<DomainId> ids)
|
|
{
|
|
return Clone(clone => clone.Ids = ids.ToList());
|
|
}
|
|
|
|
public Q WithIds(string? ids)
|
|
{
|
|
if (!string.IsNullOrEmpty(ids))
|
|
{
|
|
return Clone(clone =>
|
|
{
|
|
var idsList = new List<DomainId>();
|
|
|
|
foreach (var id in ids.Split(','))
|
|
{
|
|
idsList.Add(DomainId.Create(id));
|
|
}
|
|
|
|
clone.Ids = idsList;
|
|
});
|
|
}
|
|
|
|
return this;
|
|
}
|
|
}
|
|
}
|
|
|