public static List<Photo> GetTop100Photos(TopPhotoType topPhotoType) { string OrderByClause = string.Empty; switch (topPhotoType) { case TopPhotoType.Featured: OrderByClause = "Featured"; break; case TopPhotoType.Discussed: OrderByClause = "NumberOfComments"; break; case TopPhotoType.Viewed: OrderByClause = "NumberOfViews"; break; case TopPhotoType.Rated: OrderByClause = "TotalVoteScore"; break; } Database db = DatabaseFactory.CreateDatabase(); DbCommand dbcommand = db.GetStoredProcCommand("HG_GetTop100Photos"); db.AddInParameter(dbcommand, "OrderByClause", DbType.String, OrderByClause); List<Photo> Photos = null; //execute the stored procedure using (IDataReader dr = db.ExecuteReader(dbcommand)) { Photos = Photo.PopulatePhotoWithJoin(dr); } // Create the object array from the datareader return Photos; }
public static List <Photo> GetTop100Photos(TopPhotoType topPhotoType) { string OrderByClause = string.Empty; switch (topPhotoType) { case TopPhotoType.Featured: OrderByClause = "Featured"; break; case TopPhotoType.Discussed: OrderByClause = "NumberOfComments"; break; case TopPhotoType.Viewed: OrderByClause = "NumberOfViews"; break; case TopPhotoType.Rated: OrderByClause = "TotalVoteScore"; break; } Database db = DatabaseFactory.CreateDatabase(); DbCommand dbcommand = db.GetStoredProcCommand("HG_GetTop100Photos"); db.AddInParameter(dbcommand, "OrderByClause", DbType.String, OrderByClause); List <Photo> Photos = null; //execute the stored procedure using (IDataReader dr = db.ExecuteReader(dbcommand)) { Photos = Photo.PopulatePhotoWithJoin(dr); } // Create the object array from the datareader return(Photos); }