namespace Bit.Seeder; /// /// Base interface for query operations in the seeding system. The base interface should not be used directly, rather use `IQuery<TRequest, TResult>`. /// /// /// Queries are read-only operations that retrieve data from the seeding context. /// Unlike scenes, which create data, queries fetch existing data based on request parameters. /// They follow a type-safe pattern using generics to ensure proper request/response handling /// while maintaining a common non-generic interface for dynamic invocation. /// public interface IQuery { /// /// Gets the type of request this query expects. /// /// The request type that this query can process. Type GetRequestType(); /// /// Executes the query based on the provided request object. /// /// The request object containing parameters for the query operation. /// The query result data as an object. Task Execute(object request); } /// /// Generic query interface for read-only operations with specific request and result types. /// /// The type of request object this query accepts. /// The type of data this query returns. /// /// Use this interface when you need to retrieve existing data from the seeding context based on /// specific request parameters. Queries do not modify data - they only read /// and return information. The explicit interface implementations allow dynamic invocation while /// maintaining type safety in the implementation. /// public interface IQuery : IQuery where TRequest : class where TResult : class { /// /// Executes the query based on the provided strongly-typed request and returns typed result data. /// /// The request object containing parameters for the query operation. /// The typed query result data. Task Execute(TRequest request); /// /// Gets the request type for this query. /// /// The type of TRequest. Type IQuery.GetRequestType() => typeof(TRequest); /// /// Adapts the non-generic Execute to the strongly-typed version. /// /// The request object to cast and process. /// The typed result cast to object. async Task IQuery.Execute(object request) => await Execute((TRequest)request); }