Exemple #1
0
 private static ISourceFilter GetSourceFilter(SourceFilterDescriptor <Person> sr, SearchParam p)
 {
     if (p.isInclude)
     {
         if (p.sources == null || p.sources.Count == 0)
         {
             return(sr.ExcludeAll());
         }
         else
         {
             return(sr.Includes(inc => inc.Fields(p.sources.Select(s => s.ToString()).ToArray())));
         }
     }
     else
     {
         if (p.sources == null || p.sources.Count == 0)
         {
             return(sr.IncludeAll());
         }
         else
         {
             return(sr.Excludes(exc => exc.Fields(p.sources.Select(s => s.ToString()).ToArray())));
         }
     }
 }
Exemple #2
0
        public ISourceFilter GetSource(SourceFilterDescriptor <T> sr, QueryDes qd)
        {
            if (qd.Srcs == null || qd.Srcs.Count == 0)
            {
                return(qd.IsInclude ? sr.ExcludeAll() : sr.IncludeAll());
            }

            var arr = qd.Srcs.Select(fld => fld.ToString()).ToArray();

            return(qd.IsInclude ? sr.Includes(f => f.Fields(arr)) : sr.Excludes(f => f.Fields(arr)));
        }
Exemple #3
0
        /// <summary>
        /// 构建返回字段过滤器
        /// </summary>
        /// <param name="fields">字段投影</param>
        /// <returns></returns>
        public SourceFilterDescriptor <T> BuildFields(SearchSourceFilter fields)
        {
            if (fields == null)
            {
                return(null);
            }
            var fieldDesc = new SourceFilterDescriptor <T>()
                            .IncludeAll();

            if (fields.Excludes != null && fields.Excludes.Count > 0)
            {
                fieldDesc = fieldDesc.Excludes(ec => ec.Fields(fields.Excludes.ToArray()));
            }
            if (fields.Includes != null && fields.Includes.Count > 0)
            {
                fieldDesc = fieldDesc.Includes(ic => ic.Fields(fields.Includes.ToArray()));
            }

            return(fieldDesc);
        }