Init
This commit is contained in:
39
Prefab/Data/Queries/EntityAuditQueries.cs
Normal file
39
Prefab/Data/Queries/EntityAuditQueries.cs
Normal 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);
|
||||
}
|
||||
Reference in New Issue
Block a user