![]() |
VOOZH | about |
dotnet add package XperienceCommunity.QueryExtensions --version 1.2.0
NuGet\Install-Package XperienceCommunity.QueryExtensions -Version 1.2.0
<PackageReference Include="XperienceCommunity.QueryExtensions" Version="1.2.0" />
<PackageVersion Include="XperienceCommunity.QueryExtensions" Version="1.2.0" />Directory.Packages.props
<PackageReference Include="XperienceCommunity.QueryExtensions" />Project file
paket add XperienceCommunity.QueryExtensions --version 1.2.0
#r "nuget: XperienceCommunity.QueryExtensions, 1.2.0"
#:package XperienceCommunity.QueryExtensions@1.2.0
#addin nuget:?package=XperienceCommunity.QueryExtensions&version=1.2.0Install as a Cake Addin
#tool nuget:?package=XperienceCommunity.QueryExtensions&version=1.2.0Install as a Cake Tool
This package provides a set of extension methods for Kentico Xperience 13.0 DocumentQuery, MultiDocumentQuery, ObjectQuery, and IPageRetriever data access APIs.
This package is compatible with ASP.NET Core 3.1 → ASP.NET Core 5 applications or libraries integrated with Kentico Xperience 13.0.
Install the NuGet package in your ASP.NET Core project (or class library)
dotnet add package XperienceCommunity.QueryExtensions
Add the correct using to have the extensions appear in intellisense
using XperienceCommunity.QueryExtensions.Documents;
using XperienceCommunity.QueryExtensions.Objects;
using XperienceCommunity.QueryExtensions.Collections;
The extension methods are all in explicit namespaces to prevent conflicts with extensions that Xperience might add in the future or extensions that the developer might have already created.
If you are using C# 10, you can apply these globally with C# 10 implicit usings
using XperienceCommunity.QueryExtensions.Documents;
These work for both
DocumentQuery<T>andMultiDocumentQuery
public void QueryDocument(Guid nodeGuid)
{
var query = DocumentHelper.GetDocuments()
.WhereNodeGUIDEquals(nodeGuid);
}
public void QueryDocument(int nodeID)
{
var query = DocumentHelper.GetDocuments()
.WhereNodeIDEquals(nodeID);
}
public void QueryDocument(int documentID)
{
var query = DocumentHelper.GetDocuments()
.WhereDocumentIDEquals(documentID);
}
var query = DocumentHelper.GetDocuments()
.OrderByNodeOrder();
var query = DocumentHelper.GetDocuments()
.Tap(q =>
{
// access the query 'q'
});
bool condition = ...
var query = DocumentHelper.GetDocuments()
.If(condition, q =>
{
// when condition is true
});
bool condition = ...
var query = DocumentHelper.GetDocuments()
.If(condition,
q =>
{
// when condition is true
},
q =>
{
// when condition is false
});
var query = DocumentHelper.GetDocuments()
.OrderByDescending(nameof(TreeNode.NodeID))
.TopN(1)
.DebugQuery();
/*
--- BEGIN [path\to\your\app\Program.cs] QUERY ---
DECLARE @DocumentCulture nvarchar(max) = N'en-US';
SELECT TOP 1 *
FROM View_CMS_Tree_Joined AS V WITH (NOLOCK, NOEXPAND) LEFT OUTER JOIN COM_SKU AS S WITH (NOLOCK) ON [V].[NodeSKUID] = [S].[SKUID]
WHERE [DocumentCulture] = @DocumentCulture
ORDER BY NodeID DESC
--- END [path\to\your\app\Program.cs] QUERY ---
*/
var query = DocumentHelper.GetDocuments()
.OrderByDescending(nameof(TreeNode.NodeID))
.TopN(1)
.DebugQuery("Newest Document");
/*
--- BEGIN [Newest Document] QUERY ---
DECLARE @DocumentCulture nvarchar(max) = N'en-US';
SELECT TOP 1 *
FROM View_CMS_Tree_Joined AS V WITH (NOLOCK, NOEXPAND) LEFT OUTER JOIN COM_SKU AS S WITH (NOLOCK) ON [V].[NodeSKUID] = [S].[SKUID]
WHERE [DocumentCulture] = @DocumentCulture
ORDER BY NodeID DESC
--- END [Newest Document] QUERY ---
*/
var query = DocumentHelper.GetDocuments()
.OrderByDescending(nameof(TreeNode.NodeID))
.TopN(1)
.TapQueryText(fullQueryText =>
{
Debug.WriteLine(fullQueryText);
})
.WhereEquals(...)
public void QueryDatabase(ILogger logger)
{
var query = DocumentHelper.GetDocuments()
.OrderByDescending(nameof(TreeNode.NodeID))
.TopN(1)
.LogQuery(logger, "Logged Query");
}
var query = DocumentHelper.GetDocuments()
.Where(w => w.WhereInPath("path1", "path2"));
using XperienceCommunity.QueryExtensions.Objects;
return UserInfo.Provider.Get()
.Tap(q =>
{
// access the query
});
bool condition = ...
var query = UserInfo.Provider.Get()
.If(condition, q =>
{
// when condition is true
});
bool condition = ...
var query = UserInfo.Provider.Get()
.If(condition,
q =>
{
// when condition is true
},
q =>
{
// when condition is false
});
var query = UserInfo.Provider.Get()
.OrderByDescending(nameof(UserInfo.UserLastModified))
.TopN(1)
.DebugQuery();
/*
--- BEGIN [path\to\your\app\Program.cs] QUERY ---
SELECT TOP 1 *
FROM CMS_User
ORDER BY UserLastModified DESC
--- END [path\to\your\app\Program.cs] QUERY ---
*/
var query = UserInfo.Provider.Get()
.OrderByDescending(nameof(UserInfo.UserLastModified))
.TopN(1)
.DebugQuery("User");
/*
--- QUERY [User] START ---
SELECT TOP 1 *
FROM CMS_User
ORDER BY UserLastModified DESC
--- QUERY [User] END ---
*/
public void QueryDatabase(ILogger logger)
{
var query = UserInfo.Provider.Get()
.OrderByDescending(nameof(UserInfo.UserLastModified))
.TopN(1)
.LogQuery(logger, "Logged User Query");
}
var query = UserInfo.Provider.Get()
.TapQueryText(text =>
{
// do something with the query text
});
var query = UserInfo.Provider.Get()
.Source(s => s.InnerJoin<UserSettingInfo>(
"UserID",
"UserSettingUserID",
"MY_ALIAS",
new WhereCondition("MY_ALIAS.UserWaitingForApproval", QueryOperator.Equals, true),
new[] { SqlHints.NOLOCK }))
.TopN(1)
.DebugQuery("User");
/*
--- QUERY [User] START ---
SELECT TOP 1 *
FROM CMS_User
INNER JOIN CMS_UserSetting AS MY_ALIAS WITH (NOLOCK) ON UserID = MY_ALIAS.UserSettingUserID AND MY_ALIAS.UserWaitingForApproval = 1
ORDER BY UserLastModified DESC
--- QUERY [User] END ---
*/
using XperienceCommunity.QueryExtensions.Collections;
TreeNode? page = await retriever
.RetrieveAsync<TreeNode>(q => q.TopN(1), cancellationToken: token)
.FirstOrDefaultAsync();
IList<TreeNode> pages = await retriever
.RetrieveAsync<TreeNode>(cancellationToken: token)
.ToListAsync();
IList<TreeNode> pages = await retriever
.RetrieveAsync<TreeNode>(cancellationToken: token)
.ToArrayAsync();
using Kentico.Content.Web.Mvc;
void GetPages(int pageIndex, int pageSize)
{
var result = await retriever.RetrievePagedAsync<TreeNode>(
pageIndex,
pageSize,
q => q.OrderByNodeOrder(),
cancellationToken: token);
int total = result.TotalRecords;
List<TreeNode> pages = result.Items;
// or
var (totalRecords, pages) = await retriever.RetrievePagedAsync<TreeNode>(
pageIndex,
pageSize,
q => q.OrderByNodeOrder(),
cancellationToken: token);
}
var dataSet = await XperienceCommunityConnectionHelper.ExecuteQueryAsync("CMS.User", "GetAllUsersCustom");
string queryText = @"
SELECT *
FROM CMS_User
WHERE UserID = @UserID
"
var queryParams = new QueryDataParameters
{
{ "UserID", 3 }
};
var dataSet = await XperienceCommunityConnectionHelper.ExecuteQueryAsync(queryText, queryParams, token: token);
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 was computed. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp3.1 netcoreapp3.1 is compatible. |
Showing the top 1 NuGet packages that depend on XperienceCommunity.QueryExtensions:
| Package | Downloads |
|---|---|
|
XperienceCommunity.Baseline.Core.Library.KX13
The Baseline a set of Core Systems, Tools, and Structure to ensure a superior Kentico Website that's easy to migrate, for Kentico Xperience 13 and eventually Xperience by Kentico |
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2.0.0-prerelease-6-1 | 1,010 | 1/26/2023 |
| 1.3.0-prerelease-5-1 | 838 | 11/15/2022 |
| 1.2.0 | 36,778 | 10/5/2022 |
| 1.2.0-prerelease-4-1 | 840 | 10/4/2022 |
| 1.1.0 | 15,303 | 4/10/2022 |
| 1.1.0-prerelease-3-1 | 925 | 4/10/2022 |
| 1.1.0-prerelease-2-1 | 846 | 4/10/2022 |
| 1.0.0 | 4,446 | 1/2/2022 |
| 1.0.0-beta.5 | 307 | 1/2/2022 |
| 1.0.0-beta.4 | 298 | 1/2/2022 |
| 1.0.0-beta.3 | 374 | 11/18/2021 |
| 1.0.0-beta.2 | 362 | 11/18/2021 |
| 1.0.0-beta.1 | 334 | 11/4/2021 |