using System.Linq.Expressions; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Query; using SVSim.Database.Models; namespace SVSim.Database.Services.Inventory; /// /// Caller-supplied extra .Include chains on top of the canonical viewer-inventory query /// in . Use to bring in extra collections needed by /// the calling controller (e.g. MissionData, BuildDeckPurchases). /// /// Also carries the tag that /// stamps onto every viewer_acquire_history row written from this transaction. Callers /// that don't set end up with rows; /// grep for acquire_type=0 in dev to find unmigrated sites. /// /// public sealed class InventoryLoadConfig { internal List, IQueryable>> Includes { get; } = new(); /// /// Logical source of every grant queued in this transaction. Defaults to /// . /// public GrantSource Source { get; set; } = GrantSource.Unknown; public InventoryLoadConfig WithInclude( Expression> path) { Includes.Add(q => q.Include(path)); return this; } public InventoryLoadConfig WithInclude( Expression>> collectionPath, Expression> thenPath) { Includes.Add(q => q.Include(collectionPath).ThenInclude(thenPath)); return this; } }