Exemplo n.º 1
0
 /// <summary>
 /// Executes the query
 /// </summary>
 /// <param name="commandText">command to run</param>
 /// <returns>list of mapped records</returns>
 protected List <TReturnType> ExecuteQuery(string commandText)
 {
     using (SqlCommand _Command = QueryService.ConfigureStoredProcedureCommand(commandText, _Parameters, _ConnectionString))
     {
         return(QueryService.MapResults(_Command, Mapper));
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Executes the command and returns a return code (usually the inserted/deleted item Id)
        /// </summary>
        /// <param name="commandText">command to run</param>
        /// <returns>output of the command</returns>
        protected int ExecuteNonQuery(string commandText)
        {
            var returnParam = new SqlParameter("@ReturnValue", SqlDbType.Int)
            {
                Direction = ParameterDirection.ReturnValue
            };

            _Parameters.Add(returnParam);

            using (SqlCommand _Command = QueryService.ConfigureStoredProcedureCommand(commandText, _Parameters, _ConnectionString))
            {
                _Command.ExecuteNonQuery();
                QueryService.DisposeOfConnection(_Command);

                return((int)returnParam.Value);
            }
        }