本文整理汇总了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);
}
示例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());
}
示例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());
}
}
}
示例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());
}
}
示例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());
}
}