• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# QueryOptions类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中QueryOptions的典型用法代码示例。如果您正苦于以下问题:C# QueryOptions类的具体用法?C# QueryOptions怎么用?C# QueryOptions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



QueryOptions类属于命名空间,在下文中一共展示了QueryOptions类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: GroupingSerach

 /// <summary>
 /// </summary>
 /// <param name="dictPars">查询参数字典</param>
 /// <param name="start">分页开始标识</param>
 /// <param name="rows">每页数量</param>
 /// <param name="startTime">开始时间</param>
 /// <param name="endTime">结束时间</param>
 /// <param name="count">输出参数 总个数</param>
 /// <returns></returns>
 /// <remarks>peng.li 2015年7月23日14:11:43</remarks>
 public static List<int> GroupingSerach(Dictionary<string, string> dictPars, int start, int rows,
     DateTime startTime, DateTime endTime, out int count)
 {
     //定义solr
     var solr = ServiceLocator.Current.GetInstance<ISolrOperations<LogItems>>();
     var queryOptions = new QueryOptions();
     //定义分组
     var groupingParameters = new GroupingParameters();
     groupingParameters.Fields = new Collection<string> { "logs_id" };
     groupingParameters.Ngroups = true; //设置查询分组的总个数为true
     //定义过滤条件
     var timeRange = new SolrQueryByRange<DateTime>("logs_time", startTime, endTime);
     queryOptions.AddFilterQueries(timeRange);
     foreach (string key in dictPars.Keys)
     {
         queryOptions.AddFilterQueries(new SolrQueryByField(key, dictPars[key]));
     }
     //定义排序
     queryOptions.OrderBy = new Collection<SortOrder> { new SortOrder("logs_id", Order.DESC) };
     queryOptions.Grouping = groupingParameters;
     queryOptions.Start = start;
     queryOptions.Rows = rows;
     SolrQueryResults<LogItems> res = solr.Query(SolrQuery.All, queryOptions);
     GroupedResults<LogItems> items = res.Grouping["logs_id"];
     count = items.Ngroups ?? 0;
     return items.Groups.Select(item => Convert.ToInt32(item.GroupValue)).ToList();
 }
开发者ID:xiaopohou,项目名称:SolrDemo,代码行数:37,代码来源:SolrNetOperate.cs


示例2: ExecuteQuery

        public ISolrQueryResults<BaseballGame> ExecuteQuery()
        {
            List<ISolrQuery> fieldQueries = new List<ISolrQuery>();
            QueryOptions options = new QueryOptions();
            options.Facet = BuildBaseFacetQuery();
            options.Rows = 200;

            if (this.AppliedFacets.Count > 0)
            {
                var facetGroups = this.AppliedFacets.Select(t => t.Item1).Distinct().ToList();

                foreach(var group in facetGroups)
                {
                    List<ISolrQuery> queries = this.AppliedFacets.Where(fg => fg.Item1 == group).Select(q => new SolrQueryByField(q.Item1, q.Item2) as ISolrQuery).ToList();
                    SolrMultipleCriteriaQuery smcq =
                        new SolrMultipleCriteriaQuery(queries,"OR");
                    fieldQueries.Add(smcq);
                }

                ISolrQuery multipleCriteriaQuery = new SolrMultipleCriteriaQuery(fieldQueries, "AND");
                options.AddFilterQueries(multipleCriteriaQuery);
            }
            options.OrderBy.Add(new SortOrder(this.CurrentSortTerm, this.SortDirection == "D" ? Order.DESC : Order.ASC));
            options.AddFilterQueries(new SolrQueryByField("docType", DocType.BaseballGame.ToString()));
            ISolrQuery finalQuery = SolrQuery.All;

            if (!string.IsNullOrEmpty(this.SearchTerm))
            {
                finalQuery = new SolrQuery(this.SearchTerm);
            }

            return _solrOperations.Query(finalQuery, options);
        }
开发者ID:mondok,项目名称:Solr-Baseball-Stats-Demo,代码行数:33,代码来源:BaseballQueryBuilder.cs


示例3: AddFields

 public void AddFields()
 {
     QueryOptions o = new QueryOptions().AddFields("f1", "f2");
     Assert.AreEqual(2, o.Fields.Count);
     Assert.AreEqual("f1", o.Fields.First());
     Assert.AreEqual("f2", o.Fields.ElementAt(1));
 }
开发者ID:holytshirt,项目名称:SolrNet,代码行数:7,代码来源:QueryOptionsTests.cs


示例4: KeepassFilesThatPassOrFail

        public async Task KeepassFilesThatPassOrFail()
        {
            var queryOptions = new QueryOptions(CommonFileQuery.OrderByName, new[] { ".kdbx" });
            queryOptions.FolderDepth = FolderDepth.Shallow;


            var samples = await Package.Current.InstalledLocation.GetFolderAsync("Samples");
            var query = samples.CreateFileQueryWithOptions(queryOptions);
            IReadOnlyList<StorageFile> fileList = await query.GetFilesAsync();

            var listOfFails = new List<object>();

            foreach (var file in fileList)
            {
                string lastFileToTry = file.Name;
                try
                {
                    await Scenarios.LoadDatabase(file, "password", null);

                }
                catch (Exception e)
                {
                    listOfFails.Add(lastFileToTry);
                }
            }

            Assert.AreEqual(listOfFails.Count(), 7);
        }
开发者ID:TheAngryByrd,项目名称:MetroPass,代码行数:28,代码来源:DictionaryAttackDatabaseTests.cs


示例5: Translate

        public virtual object Translate(LinqExpression expression, QueryOptions queryOptions)
        {
            this.rootCriteria = null;
            this.options = queryOptions;

            return TranslateInternal(expression);
        }
开发者ID:pruiz,项目名称:nhibernate-contrib-old,代码行数:7,代码来源:NHibernateQueryTranslator.cs


示例6: DoCleanup

        sealed protected override async Task DoCleanup(Regex pattern, DateTime threshold)
        {

            var toDelete = new List<StorageFile>();
            foreach (var file in await _logFolder.GetFilesAsync())
            {
                if (pattern.Match(file.Name).Success && file.DateCreated <= threshold)
                    toDelete.Add(file);
            }

            
            var qo = new QueryOptions(CommonFileQuery.DefaultQuery, new [] {".zip"})
                {
                    FolderDepth = FolderDepth.Shallow,
                    UserSearchFilter = "System.FileName:~<\"Log -\""
                };

            var query = ApplicationData.Current.TemporaryFolder.CreateFileQueryWithOptions(qo);

            var oldLogs = await query.GetFilesAsync();
            toDelete.AddRange(oldLogs);

            // walk...
            foreach (var file in toDelete)
            {
                try
                {
                    await file.DeleteAsync();
                }
                catch (Exception ex)
                {
                    InternalLogger.Current.Warn(string.Format("Failed to delete '{0}'.", file.Path), ex);
                }
            }
        }
开发者ID:simonferquel,项目名称:MetroLog,代码行数:35,代码来源:WinRTFileTarget.cs


示例7: GetRealTimeData

        public dynamic GetRealTimeData(QueryOptions queryOptions, string token)
        {
            using (var client = new HttpClient())
            {
                client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);

                var url = queryOptions.Dimensions == null
                    ? string.Format(
                        "https://content.googleapis.com/analytics/v3/data/realtime?ids={0}&metrics={1}",
                        queryOptions.TableId, queryOptions.Metrics)
                    : string.Format(
                        "https://content.googleapis.com/analytics/v3/data/realtime?ids={0}&metrics={1}&dimensions={2}",
                        queryOptions.TableId, queryOptions.Metrics, queryOptions.Dimensions);

                var result =
                    client.GetAsync(url).GetAwaiter().GetResult();

                switch (result.StatusCode)
                {
                    case HttpStatusCode.Unauthorized:
                        throw new UnauthorizedException();
                    case HttpStatusCode.BadRequest:
                        throw new Exception("GetRealTimeData: Bad Request");
                }

                var json =
                    result.Content.ReadAsStringAsync().GetAwaiter().GetResult();

                return JsonConvert.DeserializeObject(json);
            }
        }
开发者ID:saitolabs,项目名称:ga-reader,代码行数:31,代码来源:GoogleApiClient.cs


示例8: GetQueryOptions

      protected QueryOptions GetQueryOptions()
      {
          MembershipUser user = Membership.GetUser();
          Guid ui;
          QueryOptions qo;

          if (user == null) 
              ui = GetGuestId();       // Get the guest user id.
          else
            ui = (Guid)user.ProviderUserKey;
          qo = db.QueryOptions.FirstOrDefault(QueryOptions => QueryOptions.UserId.Equals(ui));
          if (qo == null)
          {   // create the default user profile
              qo = new QueryOptions
              {
                  IncludeExternal = false,
                  Databases = new List<Database>(),
                  DataFields = new List<DataField>(),
                  SortOptionId = 1,
                  UserId = ui
              };
              db.QueryOptions.Add(qo);
              db.SaveChanges();
          }
          return qo;
      }
开发者ID:jbunzel,项目名称:MvcRQ_git,代码行数:26,代码来源:UserSettingsService.cs


示例9: Init

        //public ObservableCollection<ImageItem> Source = new ObservableCollection<ImageItem>();

        public async Task Init()
        {
            var queryOptions = new QueryOptions(CommonFileQuery.OrderByDate,
                new string[] { ".jpg", ".png", ".jpeg", ".bmp" })
            {
                FolderDepth = FolderDepth.Deep,
                IndexerOption = IndexerOption.OnlyUseIndexer,
                UserSearchFilter = "System.Kind:=System.Kind#Picture"
            };
            queryOptions.SetThumbnailPrefetch(ThumbnailMode.SingleItem, 256, ThumbnailOptions.UseCurrentScale);
            var _fileQueryResult = KnownFolders.PicturesLibrary.CreateFileQueryWithOptions(queryOptions);
            var files = await _fileQueryResult.GetFilesAsync();
            Debug.WriteLine("Count " + files.Count);
            var list = new List<ImageItem>();
            foreach (var f in files)
            {
                list.Add(new ImageItem()
                {
                    LocalPath = f.Path
                });
            }

            Source = new RangeCollection(list);
            Source.Init();
        }
开发者ID:HppZ,项目名称:UniversalTest,代码行数:27,代码来源:MainController.cs


示例10: GetMatchingFilesByPrefixAsync

        public static async Task<List<string>> GetMatchingFilesByPrefixAsync(string prefix, List<string> excludeFiles)
        {
            try
            {
                List<string> result = new List<string>();
                var folder = ApplicationData.Current.LocalFolder;
                QueryOptions queryOptions = new QueryOptions(CommonFileQuery.DefaultQuery, new List<string>() { "*" });
                queryOptions.UserSearchFilter = $"{prefix}*.*";
                queryOptions.FolderDepth = FolderDepth.Shallow;
                queryOptions.IndexerOption = IndexerOption.UseIndexerWhenAvailable;
                StorageFileQueryResult queryResult = folder.CreateFileQueryWithOptions(queryOptions);

                IReadOnlyList<StorageFile> matchingFiles = await queryResult.GetFilesAsync();

                if (matchingFiles.Count > 0)
                {
                    result.AddRange(
                        matchingFiles.Where(f => !excludeFiles.Contains(f.Name)).Select(f => f.Name)
                    );
                }
                return result;
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            return null;
        }
开发者ID:chengchencc,项目名称:CC.GeneralCode,代码行数:28,代码来源:UserStorage.cs


示例11: QueryOption

        public void QueryOption()
        {
            var queryOption = new QueryOptions<FakeModel>();
            queryOption.QueryExpressions.Add(f => f.Property1 == "Property1");

            queryOption.QueryExpressions.Should().HaveCount(1);
        }
开发者ID:sunilmunikar,项目名称:BestPractices,代码行数:7,代码来源:GenericQueryOptionsTests.cs


示例12: BrowseButton_Click

		private async void BrowseButton_Click(object sender, RoutedEventArgs e)
		{
			try
			{
				var folderPicker = new FolderPicker()
				{
					CommitButtonText = "Open",
					SuggestedStartLocation = PickerLocationId.DocumentsLibrary,
					ViewMode = PickerViewMode.List
				};
				folderPicker.FileTypeFilter.Add(".shp");

				_folder = await folderPicker.PickSingleFolderAsync();
				if (_folder != null)
				{
					var qopts = new QueryOptions(CommonFileQuery.OrderByName, new string[] { ".shp" });
					var query = _folder.CreateFileQueryWithOptions(qopts);
					var files = await query.GetFilesAsync();
					FileListCombo.ItemsSource = files;
					FileListCombo.Visibility = (files.Any()) ? Visibility.Visible : Visibility.Collapsed;
				}
			}
			catch (Exception ex)
			{
				var _ = new MessageDialog(ex.Message, "Sample Error").ShowAsync();
			}
		}
开发者ID:MagicWang,项目名称:arcgis-runtime-samples-dotnet,代码行数:27,代码来源:FeatureLayerFromShapefile.xaml.cs


示例13: Client_SetQueryOptions

 public void Client_SetQueryOptions()
 {
     var client = new Client();
     var opts = new QueryOptions()
     {
         Datacenter = "foo",
         Consistency = ConsistencyMode.Consistent,
         WaitIndex = 1000,
         WaitTime = new TimeSpan(0, 0, 100),
         Token = "12345"
     };
     var request = client.CreateQuery("/v1/kv/foo", opts);
     try
     {
         request.Execute();
     }
     catch (Exception)
     {
         // ignored
     }
     Assert.AreEqual("foo", request.Params["dc"]);
     Assert.IsTrue(request.Params.ContainsKey("consistent"));
     Assert.AreEqual("1000", request.Params["index"]);
     Assert.AreEqual("1m40s", request.Params["wait"]);
     Assert.AreEqual("12345", request.Params["token"]);
 }
开发者ID:Pliner,项目名称:consuldotnet,代码行数:26,代码来源:ClientTest.cs


示例14: GivenQueryOptionForFakeModel_ShouldCastToAnotherFakeModel

        public void GivenQueryOptionForFakeModel_ShouldCastToAnotherFakeModel()
        {
            var queryOption = new QueryOptions<FakeModel>();
            queryOption.QueryExpressions.Add(f => f.Property1 == "Value of Property1");

            var output = queryOption.ToLogString();
            Trace.WriteLine(output);
        }
开发者ID:sunilmunikar,项目名称:BestPractices,代码行数:8,代码来源:GenericQueryOptionsTests.cs


示例15: Translate

		public virtual object Translate(LinqExpression expression, QueryOptions queryOptions)
		{
			this.rootCriteria = null;
			this.options = queryOptions;

			Visit(expression); //ensure criteria

			var visitor = new RootVisitor(rootCriteria, session, true);
			visitor.Visit(expression);
			return visitor.Results;
		}
开发者ID:560889223,项目名称:56.NHibernate.Linq,代码行数:11,代码来源:NHibernateQueryTranslator.cs


示例16: GetCollaborationSpaces

        /// <summary>
        /// Gets a list of collaboration spaces, filtered and sorted according to the options
        /// </summary>
        /// <param name="options"></param>
        /// <returns></returns>
        public List<CollaborationSpace> GetCollaborationSpaces(QueryOptions options)
        {
            if (options == null)
                return _context.CollaborationSpaces.Take(20).ToList();

            throw new InvalidOperationException("Query not supported");

            //var positions = from p in m_ent.ProjectOpenPositions.Include("Band")
            //                where p.ProjectOpenPositionId == openPositionId
            //                select p;
        }
开发者ID:LeoLcy,项目名称:MVC6Recipes,代码行数:16,代码来源:CollaborationSpaceRepository.cs


示例17: CanWriteKeePassFiles

        public async Task CanWriteKeePassFiles()
        {
            var queryOptions = new QueryOptions(CommonFileQuery.OrderByName, new[] { ".kdbx" });
            queryOptions.FolderDepth = FolderDepth.Shallow;

            var samples = await Package.Current.InstalledLocation.GetFolderAsync("Samples2");
            var query = samples.CreateFileQueryWithOptions(queryOptions);
            IReadOnlyList<StorageFile> fileList = await query.GetFilesAsync();

            

            var writer = new Kdb4Writer(new Kdb4HeaderWriter(),
                      new WinRTCrypto(),
                      new MultiThreadedBouncyCastleCrypto(),
                      new SHA256HasherRT(),
                      new GZipFactoryRT());

            var listOfFails = new List<object>();

            foreach (var file in fileList)
            {
                PwDatabase database = null;
                string lastFileToTry = file.Name;

                await TryCleanup(lastFileToTry);
                try
                {

                    database = await Scenarios.LoadDatabase(file, "password", null);

                    var newFile = await KnownFolders.DocumentsLibrary.CreateFileAsync(lastFileToTry);
                    await writer.Write(database, new WinRTFile(newFile));
                    await Scenarios.LoadDatabase(newFile, "password", null);
                }
                catch (FormatException e)
                {
                    listOfFails.Add(lastFileToTry);
                }
                catch (Exception e)
                {
                    if(Debugger.IsAttached)
                    {
                        Debugger.Break();
                    }
                    Assert.Fail();
                }
                finally
                {
                    //TryCleanup(lastFileToTry);
                }
            }

            Assert.AreEqual(listOfFails.Count(), 7);
        }
开发者ID:TheAngryByrd,项目名称:MetroPass,代码行数:54,代码来源:DictionaryAttackDatabaseTests.cs


示例18: BuildSortableLink

 public static MvcHtmlString BuildSortableLink(this HtmlHelper htmlHelper, string fieldName, string actionName, string sortField, QueryOptions queryOptions)
 {
     var urlHelper = new UrlHelper(htmlHelper.ViewContext.RequestContext);
     var isCurrentSortField = queryOptions.SortField == sortField;
     return new MvcHtmlString(string.Format("<a href=\"{0}\">{1} {2}</a>",
                 urlHelper.Action(actionName,
                                 new {   SortField = sortField,
                                         SortOrder = (isCurrentSortField && queryOptions.SortOrder == SortOrder.ASC)? SortOrder.DESC : SortOrder.ASC}),
                                 fieldName,
                                 BuildSortIcon(isCurrentSortField, queryOptions)));
 }
开发者ID:banlong,项目名称:MVC-Knockout,代码行数:11,代码来源:HtmlHelperExtensions.cs


示例19: CollideRectangle

 public void CollideRectangle(Vector3 position, Vector3 impulse, Vector3 size, QueryOptions options, float elasticity, Viewpoint viewpoint, out MultipleHits<CollisionResult> horizontalResults, out MultipleHits<CollisionResult> verticalResults)
 {
   Vector3 impulse1 = viewpoint == Viewpoint.Front || viewpoint == Viewpoint.Back ? new Vector3(impulse.X, 0.0f, 0.0f) : new Vector3(0.0f, 0.0f, impulse.Z);
   Vector3 impulse2 = new Vector3(0.0f, impulse.Y, 0.0f);
   Vector3 halfSize = size / 2f;
   horizontalResults = this.CollideEdge(position, impulse1, halfSize, Direction2D.Horizontal, options, elasticity, viewpoint);
   verticalResults = this.CollideEdge(position, impulse2, halfSize, Direction2D.Vertical, options, elasticity, viewpoint);
   if ((options & QueryOptions.Simple) == QueryOptions.Simple || BoxCollisionResultExtensions.AnyCollided(horizontalResults) || BoxCollisionResultExtensions.AnyCollided(verticalResults))
     return;
   horizontalResults = this.CollideEdge(position + impulse2, impulse1, halfSize, Direction2D.Horizontal, options, elasticity, viewpoint);
   verticalResults = this.CollideEdge(position + impulse1, impulse2, halfSize, Direction2D.Vertical, options, elasticity, viewpoint);
 }
开发者ID:tanis2000,项目名称:FEZ,代码行数:12,代码来源:CollisionManager.cs


示例20: Get

        public List<Vehicle> Get(QueryOptions qo)
        {
            int start = QueryUtility.GetStart(qo);
            var vehicles = db.Vehicles.
                OrderBy(qo.Sort).
                Skip(start).
                Take(qo.PageSize);

            qo.TotalPages = QueryUtility.GetTotal(db.Vehicles.Count(), qo.PageSize);

            return vehicles.ToList();
        }
开发者ID:ck1521,项目名称:Slime,代码行数:12,代码来源:VehicleService.cs



注:本文中的QueryOptions类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# QueryOrderClause类代码示例发布时间:2022-05-24
下一篇:
C# QueryNode类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap