本文整理汇总了C#中WhereCondition.WhereStartsWith方法的典型用法代码示例。如果您正苦于以下问题:C# WhereCondition.WhereStartsWith方法的具体用法?C# WhereCondition.WhereStartsWith怎么用?C# WhereCondition.WhereStartsWith使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WhereCondition
的用法示例。
在下文中一共展示了WhereCondition.WhereStartsWith方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetDocumentWhereCondition
/// <summary>
/// Creates default where condition for product documents listing.
/// </summary>
private WhereCondition GetDocumentWhereCondition()
{
var where = new WhereCondition().WhereNotNull("NodeSKUID");
if (ShowSections)
{
where.Or().WhereIn("NodeClassID", new IDQuery<DataClassInfo>("ClassID").WhereTrue("ClassIsProductSection"));
}
// Prepare site condition
var siteWhere = new WhereCondition().WhereEquals("SKUSiteID", SiteContext.CurrentSiteID);
if (AllowGlobalObjects)
{
siteWhere.Or().WhereNull("SKUSiteID");
}
else if (ShowSections)
{
siteWhere.Or().Where(w => w.WhereNull("SKUSiteID").And().WhereNull("SKUID"));
}
// Combine where conditions
where.Where(siteWhere);
if (docList.Node != null)
{
string path = docList.Node.NodeAliasPath ?? "";
where.WhereStartsWith("NodeAliasPath", path);
}
return where;
}
示例2: LoadWebParts
/// <summary>
/// Reloads the web part list.
/// </summary>
/// <param name="forceLoad">if set to <c>true</c>, reload the control even if the control has been already loaded</param>
protected void LoadWebParts(bool forceLoad)
{
if (!dataLoaded || forceLoad)
{
var repeaterWhere = new WhereCondition();
/* The order is category driven => first level category display name is used for all nodes incl. sub-nodes */
string categoryOrder = @"
(SELECT CMS_WebPartCategory.CategoryDisplayName FROM CMS_WebPartCategory
WHERE CMS_WebPartCategory.CategoryPath = (CASE WHEN (CHARINDEX('/', ObjectPath, 0) > 0) AND (CHARINDEX('/', ObjectPath, CHARINDEX('/', ObjectPath, 0) + 1) = 0)
THEN ObjectPath
ELSE SUBSTRING(ObjectPath, 0, LEN(ObjectPath) - (LEN(ObjectPath) - CHARINDEX('/', ObjectPath, CHARINDEX('/', ObjectPath, 0) + 1)))
END))
";
// Set query repeater
repItems.SelectedColumns = " ObjectID, DisplayName, ObjectType, ParentID, ThumbnailGUID, IconClass, ObjectLevel, WebPartDescription, WebPartSkipInsertProperties";
repItems.OrderBy = categoryOrder + ", ObjectType DESC, DisplayName";
// Setup the where condition
if (SelectedCategory == CATEGORY_RECENTLY_USED)
{
// Recently used category
RenderRecentlyUsedWebParts(true);
}
else
{
// Specific web part category
int selectedCategoryId = ValidationHelper.GetInteger(SelectedCategory, 0);
if (selectedCategoryId > 0)
{
WebPartCategoryInfo categoryInfo = WebPartCategoryInfoProvider.GetWebPartCategoryInfoById(selectedCategoryId);
if (categoryInfo != null)
{
string firstLevelCategoryPath = String.Empty;
// Select also all subcategories (using "/%")
string categoryPath = categoryInfo.CategoryPath;
if (!categoryPath.EndsWith("/"))
{
categoryPath += "/";
}
// Do not limit items if not root category is selected
if (!categoryInfo.CategoryPath.EqualsCSafe("/"))
{
limitItems = false;
}
// Get all web parts for the selected category and its subcategories
if (categoryPath.EqualsCSafe("/"))
{
repeaterWhere.Where(repItems.WhereCondition).Where(w => w
.WhereEquals("ObjectType", "webpart")
.Or()
.WhereEquals("ObjectLevel", 1)
).Where(w => w
.WhereEquals("ParentID", selectedCategoryId)
.Or()
.WhereIn("ParentID", WebPartCategoryInfoProvider.GetCategories().WhereStartsWith("CategoryPath", categoryPath))
);
// Set caching for query repeater
repItems.ForceCacheMinutes = true;
repItems.CacheMinutes = 24 * 60;
repItems.CacheDependencies = "cms.webpart|all\ncms.webpartcategory|all";
// Show Recently used category
RenderRecentlyUsedWebParts(false);
}
else
{
// Prepare where condition -- the part that restricts web parts
repeaterWhere.WhereEquals("ObjectType", "webpart")
.Where(w => w
.WhereEquals("ParentID", selectedCategoryId)
.Or()
.WhereIn("ParentID", WebPartCategoryInfoProvider.GetCategories().WhereStartsWith("CategoryPath", categoryPath))
);
// Get first level category path
firstLevelCategoryPath = categoryPath.Substring(0, categoryPath.IndexOf('/', 2));
var selectedCategoryWhere = new WhereCondition();
// Distinguish special categories
if (categoryPath.StartsWithCSafe(CATEGORY_UIWEBPARTS, true))
{
if (!categoryPath.EqualsCSafe(firstLevelCategoryPath + "/", true))
{
// Currently selected category is one of subcategories
string specialCategoryPath = firstLevelCategoryPath;
firstLevelCategoryPath = categoryPath.Substring(CATEGORY_UIWEBPARTS.Length + 1).TrimEnd('/');
selectedCategoryWhere.WhereEquals("ObjectPath", specialCategoryPath + "/" + firstLevelCategoryPath);
}
else
//.........这里部分代码省略.........
示例3: GenerateWhereCondition
/// <summary>
/// Creates where condition according to values selected in filter.
/// </summary>
private WhereCondition GenerateWhereCondition()
{
var where = new WhereCondition();
where.And().Where(fltTaskTitle.GetCondition());
TaskTypeEnum taskType = (TaskTypeEnum)taskTypeSelector.Value.ToInteger(0);
if (taskType != TaskTypeEnum.All)
{
where.WhereStartsWith("TaskType", TaskHelper.GetTaskTypeString(taskType));
}
fltTimeBetween.Column = "TaskTime";
where.Where(fltTimeBetween.GetCondition());
var selected = ValidationHelper.GetInteger(userSelector.Value, -1);
GetStagingTasksByUser(where, selected);
var taskGroupSelected = ValidationHelper.GetInteger(stagingTaskGroupSelector.Value, -1);
GetStagingTasksByTaskGroup(where, taskGroupSelected);
return where;
}
示例4: GetLevelWhereCondition
/// <summary>
/// Creates level where condition.
/// </summary>
/// <param name="showAllLevels">Indicates if pages from all levels should be retrieved</param>
/// <param name="orderBy">Current order by</param>
private WhereCondition GetLevelWhereCondition(bool showAllLevels, ref string orderBy)
{
var levelCondition = new WhereCondition();
if (showAllLevels)
{
string path = aliasPath ?? string.Empty;
levelCondition.WhereStartsWith("NodeAliasPath", path.TrimEnd('/') + "/")
.WhereGreaterThan("NodeLevel", 0);
}
else
{
levelCondition.WhereEquals("NodeParentID", Node.NodeID)
.WhereEquals("NodeLevel", Node.NodeLevel + 1);
// Extend the where condition to include the root document
if (RequiresDialog && (Node != null) && (Node.NodeParentID == 0))
{
levelCondition.Or().WhereNull("NodeParentID");
orderBy = String.Join(",","NodeParentID ASC", orderBy);
}
}
if (ClassID > 0)
{
levelCondition.WhereEquals("NodeClassID", ClassID);
}
return levelCondition;
}