/// <summary> /// Delete the entry from persistent storage using stored procedure. /// It is a generic method, it can be used to delete any of the /// objects which implements Framework.Common.Models.IModel interface. /// </summary> /// <typeparam name="T"> /// Any type which implements Framework.Common.Models.IModel interface. /// </typeparam> /// <param name="primaryKey"> /// Primary key of the entity which is used to identify the entity. /// </param> /// <returns> /// A boolean value indicating delete operation is succesful or not. /// </returns> public bool DeleteProcedure <T>(int primaryKey) where T : IModel, new() { IFrameworkDataAccessFactory factory = DbInstance.CurrentInstance; // retrieves connection string of specified server type string connectionString = ServerManager.Instance.GetConnectionString(new T().DatabaseServerType); IDbConnection connection = factory.CreateConnection(connectionString); bool isSuccess = false; try { connection.Open(); // create common data accessor for doing database operations. IDataAccessor dataAccessor = factory.CreateAccessor(connection, typeof(T)); isSuccess = dataAccessor.DeleteProcedure(primaryKey); } finally { // Close the Connection if Opened if (connection.State == ConnectionState.Open) { connection.Close(); } } return(isSuccess); }