♻️ Replace the soft delete logic with the new shared one

This commit is contained in:
2025-11-17 23:43:59 +08:00
parent 4280168002
commit ba57becba8
9 changed files with 121 additions and 352 deletions

View File

@@ -0,0 +1,35 @@
using Microsoft.EntityFrameworkCore.Query;
namespace DysonNetwork.Shared.Data;
public static class OptionalQueryExtensions
{
public static IQueryable<T> If<T>(
this IQueryable<T> source,
bool condition,
Func<IQueryable<T>, IQueryable<T>> transform
)
{
return condition ? transform(source) : source;
}
public static IQueryable<T> If<T, TP>(
this IIncludableQueryable<T, TP> source,
bool condition,
Func<IIncludableQueryable<T, TP>, IQueryable<T>> transform
)
where T : class
{
return condition ? transform(source) : source;
}
public static IQueryable<T> If<T, TP>(
this IIncludableQueryable<T, IEnumerable<TP>> source,
bool condition,
Func<IIncludableQueryable<T, IEnumerable<TP>>, IQueryable<T>> transform
)
where T : class
{
return condition ? transform(source) : source;
}
}