Ejemplo n.º 1
0
		public IQueryable<FollowerEntity> GetFollowersByCondition(FollowerSearchCondition condition)
		{
			var query = _followerRepository.Table;
			try
			{
				if (condition.AddtimeBegin.HasValue)
                {
                    query = query.Where(q => q.Addtime>= condition.AddtimeBegin.Value);
                }
                if (condition.AddtimeEnd.HasValue)
                {
                    query = query.Where(q => q.Addtime < condition.AddtimeEnd.Value);
                }
				if (condition.UptimeBegin.HasValue)
                {
                    query = query.Where(q => q.Uptime>= condition.UptimeBegin.Value);
                }
                if (condition.UptimeEnd.HasValue)
                {
                    query = query.Where(q => q.Uptime < condition.UptimeEnd.Value);
                }
				if (!string.IsNullOrEmpty(condition.Openid))
                {
                    query = query.Where(q => q.Openid.Contains(condition.Openid));
                }
				if (!string.IsNullOrEmpty(condition.Nickname))
                {
                    query = query.Where(q => q.Nickname.Contains(condition.Nickname));
                }
				if (!string.IsNullOrEmpty(condition.Sex))
                {
                    query = query.Where(q => q.Sex.Contains(condition.Sex));
                }
				if (!string.IsNullOrEmpty(condition.City))
                {
                    query = query.Where(q => q.City.Contains(condition.City));
                }
				if (!string.IsNullOrEmpty(condition.Country))
                {
                    query = query.Where(q => q.Country.Contains(condition.Country));
                }
				if (!string.IsNullOrEmpty(condition.Private))
                {
                    query = query.Where(q => q.Private.Contains(condition.Private));
                }
				if (!string.IsNullOrEmpty(condition.Language))
                {
                    query = query.Where(q => q.Language.Contains(condition.Language));
                }
				if (!string.IsNullOrEmpty(condition.Headimgurl))
                {
                    query = query.Where(q => q.Headimgurl.Contains(condition.Headimgurl));
                }
				if (!string.IsNullOrEmpty(condition.Subscribetime))
                {
                    query = query.Where(q => q.Subscribetime.Contains(condition.Subscribetime));
                }
				if (!string.IsNullOrEmpty(condition.Unioid))
                {
                    query = query.Where(q => q.Unioid.Contains(condition.Unioid));
                }
				if (!string.IsNullOrEmpty(condition.Remark))
                {
                    query = query.Where(q => q.Remark.Contains(condition.Remark));
                }
				if (!string.IsNullOrEmpty(condition.Groupid))
                {
                    query = query.Where(q => q.Groupid.Contains(condition.Groupid));
                }
				if (condition.Ids != null && condition.Ids.Any())
                {
                    query = query.Where(q => condition.Ids.Contains(q.Id));
                }
				if (condition.Addusers != null && condition.Addusers.Any())
                {
                    query = query.Where(q => condition.Addusers.Contains(q.Adduser));
                }
				if (condition.Upusers != null && condition.Upusers.Any())
                {
                    query = query.Where(q => condition.Upusers.Contains(q.Upuser));
                }
				if(condition.OrderBy.HasValue)
				{
					switch (condition.OrderBy.Value)
                    {
						case EnumFollowerSearchOrderBy.OrderById:
							query = condition.IsDescending?query.OrderByDescending(q=>q.Id):query.OrderBy(q=>q.Id);
							break;
                    }
					
				}
				else
				{
					query = query.OrderBy(q=>q.Id);
				}

				if (condition.Page.HasValue && condition.PageCount.HasValue)
                {
                    query = query.Skip((condition.Page.Value - 1)*condition.PageCount.Value).Take(condition.PageCount.Value);
                }
				return query;
			}
			catch(Exception e)
			{
				_log.Error(e,"数据库操作出错");
                return null;
			}
		}
Ejemplo n.º 2
0
		public int GetFollowerCount (FollowerSearchCondition condition)
		{
			var query = _followerRepository.Table;
			try
			{
				if (condition.AddtimeBegin.HasValue)
                {
                    query = query.Where(q => q.Addtime>= condition.AddtimeBegin.Value);
                }
                if (condition.AddtimeEnd.HasValue)
                {
                    query = query.Where(q => q.Addtime < condition.AddtimeEnd.Value);
                }
				if (condition.UptimeBegin.HasValue)
                {
                    query = query.Where(q => q.Uptime>= condition.UptimeBegin.Value);
                }
                if (condition.UptimeEnd.HasValue)
                {
                    query = query.Where(q => q.Uptime < condition.UptimeEnd.Value);
                }
				if (!string.IsNullOrEmpty(condition.Openid))
                {
                    query = query.Where(q => q.Openid.Contains(condition.Openid));
                }
				if (!string.IsNullOrEmpty(condition.Nickname))
                {
                    query = query.Where(q => q.Nickname.Contains(condition.Nickname));
                }
				if (!string.IsNullOrEmpty(condition.Sex))
                {
                    query = query.Where(q => q.Sex.Contains(condition.Sex));
                }
				if (!string.IsNullOrEmpty(condition.City))
                {
                    query = query.Where(q => q.City.Contains(condition.City));
                }
				if (!string.IsNullOrEmpty(condition.Country))
                {
                    query = query.Where(q => q.Country.Contains(condition.Country));
                }
				if (!string.IsNullOrEmpty(condition.Private))
                {
                    query = query.Where(q => q.Private.Contains(condition.Private));
                }
				if (!string.IsNullOrEmpty(condition.Language))
                {
                    query = query.Where(q => q.Language.Contains(condition.Language));
                }
				if (!string.IsNullOrEmpty(condition.Headimgurl))
                {
                    query = query.Where(q => q.Headimgurl.Contains(condition.Headimgurl));
                }
				if (!string.IsNullOrEmpty(condition.Subscribetime))
                {
                    query = query.Where(q => q.Subscribetime.Contains(condition.Subscribetime));
                }
				if (!string.IsNullOrEmpty(condition.Unioid))
                {
                    query = query.Where(q => q.Unioid.Contains(condition.Unioid));
                }
				if (!string.IsNullOrEmpty(condition.Remark))
                {
                    query = query.Where(q => q.Remark.Contains(condition.Remark));
                }
				if (!string.IsNullOrEmpty(condition.Groupid))
                {
                    query = query.Where(q => q.Groupid.Contains(condition.Groupid));
                }
				if (condition.Ids != null && condition.Ids.Any())
                {
                    query = query.Where(q => condition.Ids.Contains(q.Id));
                }
				if (condition.Addusers != null && condition.Addusers.Any())
                {
                    query = query.Where(q => condition.Addusers.Contains(q.Adduser));
                }
				if (condition.Upusers != null && condition.Upusers.Any())
                {
                    query = query.Where(q => condition.Upusers.Contains(q.Upuser));
                }
				return query.Count();
			}
			catch(Exception e)
			{
				_log.Error(e,"数据库操作出错");
                return -1;
			}
		}