Esempio n. 1
0
        /// <summary>
        /// 创建查询对象
        /// </summary>
        /// <returns></returns>
        public override IQuery CreateQuery()
        {
            var query = base.CreateQuery() ?? QueryManager.Create <PermissionEntity>(this);

            #region 数据筛选

            if (!Ids.IsNullOrEmpty())
            {
                query.In <PermissionEntity>(c => c.Id, Ids);
            }
            if (!Codes.IsNullOrEmpty())
            {
                query.In <PermissionEntity>(c => c.Code, Codes);
            }
            if (!string.IsNullOrWhiteSpace(Name))
            {
                query.Equal <PermissionEntity>(c => c.Name, Name);
            }
            if (!string.IsNullOrWhiteSpace(NameCodeMateKey))
            {
                query.And <PermissionEntity>(QueryOperator.OR, CriteriaOperator.Like, NameCodeMateKey, a => a.Code, a => a.Name);
            }
            if (Type.HasValue)
            {
                query.Equal <PermissionEntity>(c => c.Type, Type.Value);
            }
            if (Status.HasValue)
            {
                query.Equal <PermissionEntity>(c => c.Status, Status.Value);
            }
            if (Sort.HasValue)
            {
                query.Equal <PermissionEntity>(c => c.Sort, Sort.Value);
            }
            if (Group.HasValue)
            {
                query.Equal <PermissionEntity>(c => c.Group, Group.Value);
            }
            if (!string.IsNullOrWhiteSpace(Remark))
            {
                query.Equal <PermissionEntity>(c => c.Remark, Remark);
            }
            if (CreateDate.HasValue)
            {
                query.Equal <PermissionEntity>(c => c.CreateDate, CreateDate.Value);
            }

            #endregion

            #region 数据加载

            if (LoadGroup)
            {
                query.SetLoadProperty <Permission>(true, c => c.Group);
            }

            #endregion

            return(query);
        }