public IList <IViewArtists> GetTop <IViewArtistsQueryParams>(int top, IViewArtistsQueryParams query) { _collection = new List <IViewArtists>(); string sqlCommand = "viewArtistsGetTop"; using (DbCommand dbCmd = _dataBase.GetStoredProcCommand(sqlCommand)) { _dataBase.AddInParameter(dbCmd, "@topParam", DbType.Int32, top); _dataBase.AddInParameter(dbCmd, "@fromParam", DbType.String, ((IDataQuery)query).From); _dataBase.AddInParameter(dbCmd, "@whereParam", DbType.String, ((IDataQuery)query).Where); _dataBase.AddInParameter(dbCmd, "@orderByParam", DbType.String, ((IDataQuery)query).OrderBy); using (IDataReader reader = _dataBase.ExecuteReader(dbCmd)) { while (reader.Read()) { IViewArtists viewArtists = new ViewArtists(); viewArtists.ArtistId = Convert.ToInt32(reader["artistId"].ToString()); viewArtists.Name = reader["name"].ToString(); viewArtists.Description = reader["description"].ToString(); viewArtists.Picture = reader["picture"].ToString(); _collection.Add(viewArtists); } } } return(_collection); }
public IList <IViewArtists> Find <IViewArtistsQueryParams>(IViewArtistsQueryParams query) { _collection = new List <IViewArtists>(); string sqlCommand = "viewArtistsFind"; // Create a suitable command type and add the required parameter. using (DbCommand dbCmd = _dataBase.GetStoredProcCommand(sqlCommand)) { _dataBase.AddInParameter(dbCmd, "@fromParam", DbType.String, ((IDataQuery)query).From); _dataBase.AddInParameter(dbCmd, "@whereParam", DbType.String, ((IDataQuery)query).Where); _dataBase.AddInParameter(dbCmd, "@orderByParam", DbType.String, ((IDataQuery)query).OrderBy); _dataBase.AddInParameter(dbCmd, "@pageNumber", DbType.String, ((IDataQuery)query).Page); _dataBase.AddInParameter(dbCmd, "@rowCount", DbType.String, ((IDataQuery)query).RowCount); // Call the ExecuteReader method with the command. using (IDataReader reader = _dataBase.ExecuteReader(dbCmd)) { while (reader.Read()) { IViewArtists viewArtists = new ViewArtists(); viewArtists.ArtistId = Convert.ToInt32(reader["artistId"].ToString()); viewArtists.Name = reader["name"].ToString(); viewArtists.Description = reader["description"].ToString(); viewArtists.Picture = reader["picture"].ToString(); _collection.Add(viewArtists); } } } return(_collection); }
public IViewArtists GetById(int id) { IViewArtists viewArtists = new ViewArtists(); string sqlCommand = "viewArtistsFind"; using (DbCommand dbCmd = _dataBase.GetStoredProcCommand(sqlCommand)) { IDataQuery query = new DataQuery(); query.Where = string.Format(" viewArtistsId={0} ", id); _dataBase.AddInParameter(dbCmd, "@fromParam", DbType.String, query.From); _dataBase.AddInParameter(dbCmd, "@whereParam", DbType.String, query.Where); _dataBase.AddInParameter(dbCmd, "@orderByParam", DbType.String, query.OrderBy); using (IDataReader reader = _dataBase.ExecuteReader(dbCmd)) { while (reader.Read()) { viewArtists.ArtistId = Convert.ToInt32(reader["artistId"].ToString()); viewArtists.Name = reader["name"].ToString(); viewArtists.Description = reader["description"].ToString(); viewArtists.Picture = reader["picture"].ToString(); } } } return(viewArtists); }