Exemplo n.º 1
0
        protected T FillToObject <T>()
        {
            try
            {
                if (typeof(T).FullName.StartsWith("System."))
                {
                    var tmpResult = CurrentCommand.ExecuteScalar();

                    if (tmpResult == null || Convert.IsDBNull(tmpResult))
                    {
                        return(default(T));
                    }

                    return((T)Convert.ChangeType(tmpResult, typeof(T)));
                }

                IDataReader dataReader = CurrentCommand.ExecuteReader();

                var result = CBO.Instance.FillObject <T>(dataReader);

                if (!dataReader.IsClosed)
                {
                    dataReader.Close();
                }

                dataReader.Dispose();

                return(result);
            }
            catch (Exception ex)
            {
                throw new ManagedException(ex.Message, false);
            }
        }
Exemplo n.º 2
0
 protected object ExecuteScalar(string commandText, params object[] paramValues)
 {
     try
     {
         CreateCommand(commandText, paramValues);
         return(CurrentCommand.ExecuteScalar());
     }
     catch (Exception ex)
     {
         throw new ManagedException(ex.Message, false, commandText, paramValues);
     }
 }