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.
91 lines
2.5 KiB
91 lines
2.5 KiB
// ==========================================================================
|
|
// Squidex Headless CMS
|
|
// ==========================================================================
|
|
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|
// All rights reserved. Licensed under the MIT license.
|
|
// ==========================================================================
|
|
|
|
using System;
|
|
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<Guid> Ids { get; private set; }
|
|
|
|
public Guid? 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(c => c.Query = query);
|
|
}
|
|
|
|
public Q WithODataQuery(string? odataQuery)
|
|
{
|
|
return Clone(c => c.ODataQuery = odataQuery);
|
|
}
|
|
|
|
public Q WithJsonQuery(string? jsonQuery)
|
|
{
|
|
return Clone(c => c.JsonQuery = jsonQuery);
|
|
}
|
|
|
|
public Q WithJsonQuery(Query<IJsonValue>? jsonQuery)
|
|
{
|
|
return Clone(c => c.ParsedJsonQuery = jsonQuery);
|
|
}
|
|
|
|
public Q WithIds(params Guid[] ids)
|
|
{
|
|
return Clone(c => c.Ids = ids.ToList());
|
|
}
|
|
|
|
public Q WithReference(Guid? reference)
|
|
{
|
|
return Clone(c => c.Reference = reference);
|
|
}
|
|
|
|
public Q WithIds(IEnumerable<Guid> ids)
|
|
{
|
|
return Clone(c => c.Ids = ids.ToList());
|
|
}
|
|
|
|
public Q WithIds(string? ids)
|
|
{
|
|
if (!string.IsNullOrEmpty(ids))
|
|
{
|
|
return Clone(c =>
|
|
{
|
|
var idsList = new List<Guid>();
|
|
|
|
foreach (var id in ids.Split(','))
|
|
{
|
|
if (Guid.TryParse(id, out var guid))
|
|
{
|
|
idsList.Add(guid);
|
|
}
|
|
}
|
|
|
|
c.Ids = idsList;
|
|
});
|
|
}
|
|
|
|
return this;
|
|
}
|
|
}
|
|
}
|
|
|