public static long GetMembersCount(string Province, int Sex, Member.AgeType age, Member.SearchType type,Member.HasPhotoType hasiconphoto) { Member.MemberSearch ms = new Member.MemberSearch(); ms.Province = Province; ms.Sex = Sex; ms.Type = type; ms.Age = age; ms.HasPhoto = hasiconphoto; long mc = MongoDBHelper.GetCount( "Members", ms.GetSearchQueryObj()); return mc; }
public static IList<Member.Member> GetMembers(string Province, int Sex, Member.AgeType age, Member.SearchType type, bool isRandom,Member.HasPhotoType hasiconphoto, int randomcount, int pagesize, int pageno) { Member.MemberSearch ms = new Member.MemberSearch(); ms.Province = Province; ms.Sex = Sex; ms.Type = type; ms.Age = age; ms.HasPhoto = hasiconphoto; MongoCursor<Member.Member> mc = MongoDBHelper.GetCursor<Member.Member>( "Members", ms.GetSearchQueryObj(), ms.GetOrderByObj(), pageno, pagesize); List<Member.Member> objs = new List<Member.Member>(); objs.AddRange(mc); if (isRandom) { Random rnd = new Random(DateTime.Now.Millisecond); IEnumerable<Member.Member> rndlist = objs.OrderBy(x => rnd.Next()).Take(randomcount); List<Member.Member> randomobjs = rndlist.ToList(); objs = randomobjs; } return objs; }