本文整理汇总了C#中Database.SelectItems方法的典型用法代码示例。如果您正苦于以下问题:C# Database.SelectItems方法的具体用法?C# Database.SelectItems怎么用?C# Database.SelectItems使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Database
的用法示例。
在下文中一共展示了Database.SelectItems方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Search
/// <summary>
/// Searches the specified query.
/// </summary>
/// <param name="query">The query.</param>
/// <param name="database">The database.</param>
/// <returns>Returns collection of items</returns>
public override IEnumerable<Item> Search(Query query, Database database)
{
Assert.ArgumentNotNull(query, "query");
Assert.ArgumentNotNull(database, "database");
FastQueryBuilder builder = new FastQueryBuilder(query);
return database.SelectItems(builder.BuildResultQuery());
}
示例2: GetFastQueryItems
/// <summary>
/// Use Fast Query to get all child items.
/// Option decides whether to get immediate children or all decendants
/// </summary>
/// <param name="item">The item.</param>
/// <param name="db">The db.</param>
/// <param name="fqOption">The fq option.</param>
/// <returns></returns>
public static Item[] GetFastQueryItems(this Item item, Database db, FastQueryOptions fqOption)
{
if (item == null) return null;
string path = item.Paths.Path;
string fastPath = path.QueryEscape();
string fastQueryString;
if (fqOption == FastQueryOptions.Deep)
{
fastQueryString = string.Format("fast:{0}//*", fastPath);
}
// default to shallow
else
{
fastQueryString = string.Format("fast:{0}/*", fastPath);
}
Item[] items = db.SelectItems(fastQueryString);
return items;
}
示例3: DisplayAccountRight
private void DisplayAccountRight(Database db, string account, bool showdefaultrights)
{
if (account == "all")
{
userrights.Text += string.Format("<h2 id=\"{0}\">Item Rights set on all users and roles on {0} Database</h2>", db.Name);
}
else
{
userrights.Text += string.Format("<h2 id=\"{1}\">Item Rights set on account {0} on {1} Database</h2>", System.Web.HttpUtility.HtmlEncode(account), db.Name);
}
//We use a query instead of index search because, security field data is not in query, will be slower by large resultset.
const string query = "fast://*[@__Security != '' ]";
var itemList = new List<Item>(db.SelectItems(query));
var count = 0;
var checkAccount = new CheckAccount();
string outmessage;
var defaultRights = RightsData.RightsData.GetDefaultRights(db.Name, account, out outmessage);
if (!string.IsNullOrEmpty(outmessage))
{
userrights.Text += "<p>" + outmessage + "</p>";
}
userrights.Text += "<table id=\"table-accountrights\">";
foreach (var item in itemList)
{
var accessRules = item.Security.GetAccessRules();
if (accessRules != null)
{
if (account == "devexport")
{
userrights.Text += string.Format(",new[] {{\"{0}\",@\"{1}\"}}\n<br>", item.Paths.FullPath, item.Fields["__Security"].Value);
}
else
{
foreach (var rule in accessRules)
{
var defaultRight = defaultRights.FirstOrDefault(x => x.Path == item.Paths.FullPath && x.Account == rule.Account.Name && x.Right == rule.SecurityPermission.ToString() && x.Name == rule.AccessRight.Name && x.PropagationType == rule.PropagationType.ToString());
var style = "";
var message = "";
if (defaultRight != null)
{
defaultRight.Hit = true;
style = " style=\"color:#008800;\" class=\"green\"";
message = string.Format(", ({0})", defaultRight.Message);
if (!showdefaultrights)
{
continue;
}
}
var accountExsist = true;
if (rule.Account.AccountType == AccountType.Role)
{
accountExsist = checkAccount.IsRolExsisting(rule.Account.Name);
}
else
{
accountExsist = checkAccount.IsUserExsisting(rule.Account.Name);
}
if (!accountExsist)
{
message += ", Account unknown";
style = " style=\"color:#FFA500;\" class=\"orange\"";
}
if (rule.Account.Name == account)
{
userrights.Text += string.Format("<tr{3}><td>{0}</td><td>{1}</td><td>{6}</td><td>{2}{4}</td><td>{5}</td></tr>\n", item.Paths.FullPath, rule.AccessRight.Comment, rule.SecurityPermission, style, message, rule.PropagationType, rule.AccessRight.Name);
count++;
}
else if (account == "all")
{
userrights.Text += string.Format("<tr{4}><td>{0}</td><td>{8} : {1}</td><td>{7}</td><td>{2}{5}</td><td>{3}</td><td>{6}</td></tr>\n", item.Paths.FullPath, rule.Account.Name, rule.AccessRight.Comment, rule.SecurityPermission, style, message, rule.PropagationType, rule.AccessRight.Name, rule.Account.AccountType.ToString());
count++;
}
else if (account == "alldevexport")
{
userrights.Text += string.Format(",new[] {{\"{0}\",\"{1}\",\"{2}\",\"{3}\"}}\n<br>", item.Paths.FullPath, rule.Account.Name.Replace("\\", "\\\\"), rule.SecurityPermission, rule.PropagationType);
count++;
}
}
}
}
}
if (count == 0)
{
if (showdefaultrights)
{
userrights.Text += "<tr><td>No rights found in this Database for the user or role.</td></tr>";
}
else
{
userrights.Text += "<tr><td>No custom rights found in this Database.</td></tr>";
}
}
userrights.Text += "</table>";
var warningRights = defaultRights.Where(x => x.Hit == false).ToList();
//.........这里部分代码省略.........
示例4: GetRedirects
/// <summary>
/// This method return all of the possible matches for either the exact matches or the pattern matches
/// Note: Because Fast Query does not guarantee to return items in the current language context
/// (e.g. while in US/English, results may include other language items as well, even if the
/// US/EN language has no active versions), an additional LINQ query has to be run to filter for language.
/// Choose your query type appropriately.
/// </summary>
private static IEnumerable<Item> GetRedirects(Database db, string templateName, string versionedTemplateName, string queryType)
{
// Based off the config file, we can run different types of queries.
IEnumerable<Item> ret = null;
var redirectRoot = Sitecore.Configuration.Settings.GetSetting(Constants.Settings.RedirectRootNode);
switch (queryType)
{
case "fast": // fast query
{
//process shared template items
ret = db.SelectItems(String.Format("fast:{0}//*[@@templatename='{1}']", redirectRoot, templateName));
//because fast query requires to check for active versions in the current language
//run a separate query for versioned items to see if this is even necessary.
//if only shared templates exist in System/Modules, this step is extraneous and unnecessary.
IEnumerable<Item> versionedItems = db.SelectItems(String.Format("fast:{0}//*[@@templatename='{1}']", redirectRoot, versionedTemplateName));
//if active versions of items in the current context exist, union the two IEnumerable lists together.
ret = versionedItems.Any(i => i.Versions.Count > 0)
? ret.Union(versionedItems.Where(i => i.Versions.Count > 0))
: ret;
break;
}
case "query": // Sitecore query
{
ret = db.SelectItems(String.Format("{0}//*[@@templatename='{1}' or @@templatename='{2}']", redirectRoot, templateName, versionedTemplateName));
break;
}
default: // API LINQ
{
Item redirectFolderRoot = db.SelectSingleItem(redirectRoot);
if (redirectFolderRoot != null)
ret = redirectFolderRoot.Axes.GetDescendants().Where(i => i.TemplateName == templateName || i.TemplateName == versionedTemplateName);
break;
}
}
// make sure to return an empty list instead of null
return ret ?? new Item[0];
}
示例5: GetRepositoriesUnderPath
public static IEnumerable<OpenDataAgentRepository> GetRepositoriesUnderPath(string path, Database database)
{
return database.SelectItems(path).Where(x => x.IsDerived(Templates.Repository.ID)).Select(x=> new OpenDataAgentRepository(new Repository(x)));
}
示例6: GetRedirects
/// <summary>
/// This method return all of the possible matches for either the exact matches or the pattern matches
/// </summary>
private static IEnumerable<Item> GetRedirects(Database db, string templateName, string queryType)
{
// Based off the config file, we can run different types of queries.
IEnumerable<Item> ret = null;
var redirectRoot = Sitecore.Configuration.Settings.GetSetting("SharedSource.RedirectModule.RedirectRootNode");
switch (queryType)
{
case "fast": // fast query
{
ret = db.SelectItems(String.Format("fast:{0}//*[@@templatename='{1}']", redirectRoot, templateName));
break;
}
case "query": // Sitecore query
{
ret = db.SelectItems(String.Format("{0}//*[@@templatename='{1}']", redirectRoot, templateName));
break;
}
default: // API LINQ
{
Item redirectFolderRoot = db.SelectSingleItem(redirectRoot);
if (redirectFolderRoot != null)
ret = redirectFolderRoot.Axes.GetDescendants().Where(i => i.TemplateName == templateName);
break;
}
}
// make sure to return an empty list instead of null
return ret ?? new Item[0];
}
示例7: GetLockedItems
protected virtual IEnumerable<Item> GetLockedItems(Database database)
{
Assert.ArgumentNotNull(database, "database");
return database.SelectItems("fast://*[@__lock='%owner=%']");
}