コード例 #1
0
ファイル: ESReader.cs プロジェクト: gaoshoufenmu/NoSqlDemo
 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())));
         }
     }
 }
コード例 #2
0
        private Union <bool, ISourceFilter> GetProjection(string[] fields)
        {
            var projection = new SourceFilterDescriptor <T>();

            projection.Includes(i => i.Fields(fields));

            return(projection);
        }
コード例 #3
0
ファイル: Reader.cs プロジェクト: gaoshoufenmu/Mixture
        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)));
        }
コード例 #4
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);
        }
コード例 #5
0
 private static SourceFilterDescriptor <EssayDocument> MakeSource(SourceFilterDescriptor <EssayDocument> src)
 {
     return(src.Includes(fd => fd.Field(ed => ed.Title)));
 }