示例#1
0
        public SegmentosVOCollection GetAll()
        {
            SegmentosVOCollection listaSegmentosVO = new SegmentosVOCollection();
            SegmentosVO segmentosVO = null;

            DbCommand command = db.GetStoredProcCommand("dbo.DW_SegmentosSelectAll");

            using (IDataReader reader = db.ExecuteReader(command))
            {
                while (reader.Read())
                {
                    segmentosVO = new SegmentosVO();
                    segmentosVO.IsPersisted = true;
                    if (!reader.IsDBNull(reader.GetOrdinal("IdSegmento")))
                        segmentosVO.IdSegmento = reader.GetInt32(reader.GetOrdinal("IdSegmento"));
                    if (!reader.IsDBNull(reader.GetOrdinal("Nome")))
                        segmentosVO.Nome = reader.GetString(reader.GetOrdinal("Nome")).Trim();
                    listaSegmentosVO.Add(segmentosVO);
                }
            }

            return listaSegmentosVO;
        }
示例#2
0
        public SegmentosVOCollection GetAllPaged(long startRowIndex, int maximumRows)
        {
            SegmentosVOCollection listaSegmentosVO = new SegmentosVOCollection();
            SegmentosVO segmentosVO = null;

            DbCommand command = db.GetStoredProcCommand("dbo.DW_SegmentosSelectAllPaged");
            db.AddInParameter(command, "@startRowIndex", DbType.Int64, startRowIndex);
            db.AddInParameter(command, "@maximumRows", DbType.Int64, maximumRows);

            using (IDataReader reader = db.ExecuteReader(command))
            {
                while (reader.Read())
                {
                    if (listaSegmentosVO.Count == 0) listaSegmentosVO.TotalRows = int.Parse(reader.GetValue(reader.GetOrdinal("TotalRows")).ToString());
                    segmentosVO = new SegmentosVO();
                    segmentosVO.IsPersisted = true;
                    if (!reader.IsDBNull(reader.GetOrdinal("IdSegmento")))
                        segmentosVO.IdSegmento = reader.GetInt32(reader.GetOrdinal("IdSegmento"));
                    if (!reader.IsDBNull(reader.GetOrdinal("Nome")))
                        segmentosVO.Nome = reader.GetString(reader.GetOrdinal("Nome")).Trim();
                    listaSegmentosVO.Add(segmentosVO);
                }
            }

            listaSegmentosVO.PageSize = maximumRows;

            return listaSegmentosVO;
        }