using System.Collections.Generic; using System.Data.Entity; namespace PalGain.Core { public interface IDbContext { /// /// Get DbSet /// /// Entity type /// DbSet IDbSet Set() where TEntity : BaseEntity; /// /// Save changes /// /// int SaveChanges(); /// /// Execute stores procedure and load a list of entities at the end /// /// Entity type /// Command text /// Parameters /// Entities IList ExecuteStoredProcedureList(string commandText, params object[] parameters) where TEntity : BaseEntity, new(); /// /// Creates a raw SQL query that will return elements of the given generic type. The type can be any type that has properties that match the names of the columns returned from the query, or can be a simple primitive type. The type does not have to be an entity type. The results of this query are never tracked by the context even if the type of object returned is an entity type. /// /// The type of object returned by the query. /// The SQL query string. /// The parameters to apply to the SQL query string. /// Result IEnumerable SqlQuery(string sql, params object[] parameters); /// /// Executes the given DDL/DML command against the database. /// /// The command string /// false - the transaction creation is not ensured; true - the transaction creation is ensured. /// Timeout value, in seconds. A null value indicates that the default value of the underlying provider will be used /// The parameters to apply to the command string. /// The result returned by the database after executing the command. int ExecuteSqlCommand(string sql, bool doNotEnsureTransaction = false, int? timeout = null, params object[] parameters); /// /// Detach an entity /// /// Entity void Detach(object entity); /// /// Gets or sets a value indicating whether proxy creation setting is enabled (used in EF) /// bool ProxyCreationEnabled { get; set; } /// /// Gets or sets a value indicating whether auto detect changes setting is enabled (used in EF) /// bool AutoDetectChangesEnabled { get; set; } } }