using System; using System.Collections.Generic; using System.Linq.Expressions; using System.Threading.Tasks; namespace DataConnection.Interfaces; /// /// Interfaccia per la gestione di database preesistenti tramite EF Core /// public interface IDatabaseManager : IDisposable { /// /// Verifica la connessione al database /// Task TestConnectionAsync(); /// /// Ottiene entità dal database in base ai criteri specificati /// /// Tipo di entità /// Espressione di filtro /// Espressione di ordinamento /// Proprietà di navigazione da includere /// Numero di elementi da saltare /// Numero di elementi da prendere Task> GetAsync( Expression> filter = null, Func, IOrderedQueryable> orderBy = null, string includeProperties = "", int? skip = null, int? take = null) where T : class; /// /// Ottiene un'entità singola in base alla chiave primaria /// Task GetByIdAsync(object id) where T : class; /// /// Esegue una query SQL raw /// Task> ExecuteQueryAsync(string sql, params object[] parameters) where T : class; /// /// Esegue un comando SQL che non restituisce risultati /// Task ExecuteCommandAsync(string sql, params object[] parameters); /// /// Ottiene i metadati delle tabelle nel database /// Task>> GetDatabaseSchemaAsync(); } /// /// Informazioni su una colonna del database /// public class DbColumnInfo { public string Name { get; set; } public string DataType { get; set; } public bool IsNullable { get; set; } public bool IsPrimaryKey { get; set; } public bool IsForeignKey { get; set; } public string ReferencedTable { get; set; } public string ReferencedColumn { get; set; } }