当前位置: 首页>>代码示例>>C#>>正文


C# SitecoreService.Query方法代码示例

本文整理汇总了C#中SitecoreService.Query方法的典型用法代码示例。如果您正苦于以下问题:C# SitecoreService.Query方法的具体用法?C# SitecoreService.Query怎么用?C# SitecoreService.Query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SitecoreService的用法示例。


在下文中一共展示了SitecoreService.Query方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Paths

        public AbstractView Paths(string term)
        {
            IEnumerable<PathQuery> result = new PathQuery[0];

            term = term.ToLower();

            if (term.StartsWith("/sitecore"))
            {
                ISitecoreService service = new SitecoreService("master");

                if (term.EndsWith("/"))
                {
                    result = service.Query<PathQuery>(term + "*");
                }
                else
                {
                    var parts = term.Split('/');

                    var query = parts.Take(parts.Length - 1).Aggregate((x, y) => "{0}/{1}".Formatted(x, y));

                    result = service.Query<PathQuery>(query + "/*");

                    result = result.Where(x => x.value.ToLower().StartsWith(term));
                        
                }
            }

            return new JsonView(result);
        }
开发者ID:JamesHay,项目名称:Glass.Sitecore.Mapper,代码行数:29,代码来源:QueryController.cs

示例2: Query_ReturnsItemsBeneathFolderBasedOnLanguage_TwoItemsReturned

        public void Query_ReturnsItemsBeneathFolderBasedOnLanguage_TwoItemsReturned()
        {
            //Assign
            var context = Context.Create(Utilities.CreateStandardResolver());
            context.Load(new SitecoreAttributeConfigurationLoader("Glass.Mapper.Sc.Integration"));

            var db = Sitecore.Configuration.Factory.GetDatabase("master");
            var service = new SitecoreService(db);
            string query = "/sitecore/content/Tests/SitecoreService/Query/*";
            var language = LanguageManager.GetLanguage("af-ZA");

            //Act
            var result = service.Query<StubClass>(query, language);

            //Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(2, result.Count());
        }
开发者ID:uv20,项目名称:Glass.Mapper,代码行数:18,代码来源:SitecoreServiceFixture.cs

示例3: Query_ReturnsItemsBeneathFolderBasedOnLanguage_TwoItemsReturned

        public void Query_ReturnsItemsBeneathFolderBasedOnLanguage_TwoItemsReturned()
        {
            //Assign
            Guid id = Guid.NewGuid();

            using (Db database = new Db
            {
                new Sitecore.FakeDb.DbItem("Target", new ID(id))
                {
                    new DbItem("Child1")
                    {
                        new DbField("Value")
                        {
                            {"af-ZA", 1, "test"}
                        }
                    },
                    new DbItem("Child2")
                    {
                        new DbField("Value")
                        {
                            {"af-ZA", 1, "test"}
                        }
                    },

                    new DbItem("Child3")
                }
            })
            {
                var context = Context.Create(Utilities.CreateStandardResolver());
                context.Load(new OnDemandLoader<SitecoreTypeConfiguration>(typeof(StubClass)));
                var service = new SitecoreService(database.Database);

                //this is forced on to avoid other test leaving the disabler in the incorrect state
                using (new VersionCountDisabler(VersionCountState.Enabled))
                {
                    string query = "/sitecore/content/Target/*";
                    var language = LanguageManager.GetLanguage("af-ZA");

                    //Act
                    var result = service.Query<StubClass>(query, language);

                    //Assert
                    Assert.IsNotNull(result);
                    Assert.AreEqual(2, result.Count());
                }
            }
        }
开发者ID:mikeedwards83,项目名称:Glass.Mapper,代码行数:47,代码来源:SitecoreServiceFixture.cs

示例4: Query_ReturnsItemsBeneathFolder_ThreeItemsReturned

        public void Query_ReturnsItemsBeneathFolder_ThreeItemsReturned()
        {
            //Assign
            Guid id = Guid.NewGuid();

            using (Db database = new Db
            {
                new Sitecore.FakeDb.DbItem("Target", new ID(id))
                {
                    new DbItem("Child1"),
                    new DbItem("Child2"),
                    new DbItem("Child3")
                }
            })
            {
                var context = Context.Create(Utilities.CreateStandardResolver());
                context.Load(new OnDemandLoader<SitecoreTypeConfiguration>(typeof(StubClass)));
                var service = new SitecoreService(database.Database);
                string query = "/sitecore/content/Target/*";

                //Act
                var result = service.Query<StubClass>(query);

                //Assert
                Assert.IsNotNull(result);
                Assert.AreEqual(3, result.Count());
            }
        }
开发者ID:mikeedwards83,项目名称:Glass.Mapper,代码行数:28,代码来源:SitecoreServiceFixture.cs

示例5: Query_ReturnsItemsBeneathFolderBasedOnLanguage_TwoItemsReturned

        public void Query_ReturnsItemsBeneathFolderBasedOnLanguage_TwoItemsReturned()
        {
            //Assign
            var context = Context.Create(Utilities.CreateStandardResolver());
            context.Load(new SitecoreAttributeConfigurationLoader("Glass.Mapper.Sc.Integration"));

            var db = Factory.GetDatabase("master");
            var service = new SitecoreService(db);

            //this is forced on to avoid other test leaving the disabler in the incorrect state
            using (new VersionCountDisabler(VersionCountState.Enabled))
            {
                string query = "/sitecore/content/Tests/SitecoreService/Query/*";
                var language = LanguageManager.GetLanguage("af-ZA");

                //Act
                var result = service.Query<StubClass>(query, language);

                //Assert
                Assert.IsNotNull(result);
                Assert.AreEqual(2, result.Count());
            }
        }
开发者ID:neilduncan,项目名称:Glass.Mapper,代码行数:23,代码来源:SitecoreServiceFixture.cs


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