Empty interfaces + records for IInventoryService, IInventoryTransaction, InventoryCommitResult, InventoryLoadConfig, InventoryCatalogException. Implementation lands in subsequent commits. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
32 lines
1.1 KiB
C#
32 lines
1.1 KiB
C#
using System.Linq.Expressions;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore.Query;
|
|
using SVSim.Database.Models;
|
|
|
|
namespace SVSim.Database.Services.Inventory;
|
|
|
|
/// <summary>
|
|
/// Caller-supplied extra <c>.Include</c> chains on top of the canonical viewer-inventory query
|
|
/// in <see cref="IInventoryService.BeginAsync"/>. Use to bring in extra collections needed by
|
|
/// the calling controller (e.g. <c>MissionData</c>, <c>BuildDeckPurchases</c>).
|
|
/// </summary>
|
|
public sealed class InventoryLoadConfig
|
|
{
|
|
internal List<Func<IQueryable<Viewer>, IQueryable<Viewer>>> Includes { get; } = new();
|
|
|
|
public InventoryLoadConfig WithInclude<TProperty>(
|
|
Expression<Func<Viewer, TProperty>> path)
|
|
{
|
|
Includes.Add(q => q.Include(path));
|
|
return this;
|
|
}
|
|
|
|
public InventoryLoadConfig WithInclude<TProperty, TThen>(
|
|
Expression<Func<Viewer, IEnumerable<TProperty>>> collectionPath,
|
|
Expression<Func<TProperty, TThen>> thenPath)
|
|
{
|
|
Includes.Add(q => q.Include(collectionPath).ThenInclude(thenPath));
|
|
return this;
|
|
}
|
|
}
|