예제 #1
0
        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;
        }
예제 #2
0
파일: Photo.cs 프로젝트: Shine6Z/GenXSource
        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);
        }