namespace EnvelopeGenerator.Application.Common.Interfaces.SQLExecutor; /// /// Provides methods for executing common queries on a given entity type. /// This interface abstracts away the direct usage of ORM libraries (such as Entity Framework) for querying data /// and provides asynchronous and synchronous operations for querying a collection or single entity. /// /// The type of the entity being queried. public interface IQuery { /// /// Asynchronously retrieves the first entity or a default value if no entity is found. /// /// A task that represents the asynchronous operation. The task result contains the entity or a default value. public Task FirstOrDefaultAsync(); /// /// Asynchronously retrieves a single entity or a default value if no entity is found. /// /// A task that represents the asynchronous operation. The task result contains the entity or a default value. public Task SingleOrDefaultAsync(); /// /// Asynchronously retrieves a list of entities. /// /// A task that represents the asynchronous operation. The task result contains the list of entities. public Task> ToListAsync(); /// /// Asynchronously retrieves the first entity. Throws an exception if no entity is found. /// /// A task that represents the asynchronous operation. The task result contains the first entity. public Task FirstAsync(); /// /// Asynchronously retrieves a single entity. Throws an exception if no entity is found. /// /// A task that represents the asynchronous operation. The task result contains the single entity. public Task SingleAsync(); /// /// Synchronously retrieves the first entity or a default value if no entity is found. /// /// The first entity or a default value. public TEntity? FirstOrDefault(); /// /// Synchronously retrieves a single entity or a default value if no entity is found. /// /// The single entity or a default value. public TEntity? SingleOrDefault(); /// /// Synchronously retrieves a list of entities. /// /// The list of entities. public IEnumerable ToList(); /// /// Synchronously retrieves the first entity. Throws an exception if no entity is found. /// /// The first entity. public TEntity First(); /// /// Synchronously retrieves a single entity. Throws an exception if no entity is found. /// /// The single entity. public TEntity Single(); }