Ejemplo n.º 1
0
 public int GetPropertyCount(PropertySearchCondition condition)
 {
     var query = _propertyRepository.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.UpdTimeBegin.HasValue)
         {
             query = query.Where(q => q.UpdTime>= condition.UpdTimeBegin.Value);
         }
         if (condition.UpdTimeEnd.HasValue)
         {
             query = query.Where(q => q.UpdTime < condition.UpdTimeEnd.Value);
         }
         if (!string.IsNullOrEmpty(condition.PropertyName))
         {
             query = query.Where(q => q.PropertyName.Contains(condition.PropertyName));
         }
         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.UpdUsers != null && condition.UpdUsers.Any())
         {
             query = query.Where(q => condition.UpdUsers.Contains(q.UpdUser));
         }
         return query.Count();
     }
     catch(Exception e)
     {
         _log.Error(e,"数据库操作出错");
         return -1;
     }
 }
Ejemplo n.º 2
0
        public List<PropertyModel> GetByCondition(string PropertyName="",int Page =1,int PageCount =10)
        {
            var condition = new PropertySearchCondition
            {
                Page = Page,
                PageCount = PageCount,
                PropertyName = PropertyName
            };
            var model = _propertyService.GetPropertysByCondition(condition).Select(c=>new PropertyModel
            {

                Id = c.Id,

                PropertyName = c.PropertyName,

                Adduser = new UserModel { Id = c.Adduser.Id, UserName = c.Adduser.UserName },

                Addtime = c.Addtime,

                UpdUser = new UserModel { Id = c.UpdUser.Id, UserName = c.UpdUser.UserName },

                UpdTime = c.UpdTime,

            //				Value = c.Value,

            }).ToList();
            return model;
        }
Ejemplo n.º 3
0
        public IQueryable<PropertyEntity> GetPropertysByCondition(PropertySearchCondition condition)
        {
            var query = _propertyRepository.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.UpdTimeBegin.HasValue)
                {
                    query = query.Where(q => q.UpdTime>= condition.UpdTimeBegin.Value);
                }
                if (condition.UpdTimeEnd.HasValue)
                {
                    query = query.Where(q => q.UpdTime < condition.UpdTimeEnd.Value);
                }
                if (!string.IsNullOrEmpty(condition.PropertyName))
                {
                    query = query.Where(q => q.PropertyName.Contains(condition.PropertyName));
                }
                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.UpdUsers != null && condition.UpdUsers.Any())
                {
                    query = query.Where(q => condition.UpdUsers.Contains(q.UpdUser));
                }
                if(condition.OrderBy.HasValue)
                {
                    switch (condition.OrderBy.Value)
                    {
                        case EnumPropertySearchOrderBy.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.º 4
0
 public HttpResponseMessage GetCount(string PropertyName = "", int Page = 1, int PageCount = 10)
 {
     var condition = new PropertySearchCondition
     {
         Page = Page,
         PageCount = PageCount,
         PropertyName = PropertyName
     };
     var count = _propertyService.GetPropertyCount(condition);
     return PageHelper.toJson(new { TotalCount = count, Condition = condition });
 }