This commit is contained in:
2025-10-27 17:39:18 -04:00
commit 31f723bea4
1579 changed files with 642409 additions and 0 deletions

View File

@@ -0,0 +1,39 @@
using Prefab.Domain.Common;
namespace Prefab.Data.Queries;
/// <summary>
/// Provides reusable audit-related query filters for entity sets.
/// </summary>
public static class EntityAuditQueries
{
/// <summary>
/// Filters entities created before the specified timestamp.
/// </summary>
public static IQueryable<IAudit> ThatWasCreateBefore(this IQueryable<IAudit> query, DateTime dateTime) => query.Where(x => x.CreatedOn < dateTime);
/// <summary>
/// Filters entities created after the specified timestamp.
/// </summary>
public static IQueryable<IAudit> ThatWasCreatedAfter(this IQueryable<IAudit> query, DateTime dateTime) => query.Where(x => x.CreatedOn > dateTime);
/// <summary>
/// Filters entities created between the specified start and end timestamps.
/// </summary>
public static IQueryable<IAudit> ThatWasCreatedBetween(this IQueryable<IAudit> query, DateTime start, DateTime end) => query.ThatWasCreatedAfter(start).ThatWasCreateBefore(end);
/// <summary>
/// Filters entities last modified before the specified timestamp.
/// </summary>
public static IQueryable<IAudit> ThatWasLastModifiedBefore(this IQueryable<IAudit> query, DateTime dateTime) => query.Where(x => x.LastModifiedOn < dateTime);
/// <summary>
/// Filters entities last modified after the specified timestamp.
/// </summary>
public static IQueryable<IAudit> ThatWasLastModifiedAfter(this IQueryable<IAudit> query, DateTime dateTime) => query.Where(x => x.LastModifiedOn > dateTime);
/// <summary>
/// Filters entities last modified between the specified start and end timestamps.
/// </summary>
public static IQueryable<IAudit> ThatWasLastModifiedBetween(this IQueryable<IAudit> query, DateTime start, DateTime end) => query.ThatWasLastModifiedAfter(start).ThatWasLastModifiedBefore(end);
}