Cmsql 1.1.0

dotnet add package Cmsql --version 1.1.0
                    
NuGet\Install-Package Cmsql -Version 1.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Cmsql" Version="1.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Cmsql" Version="1.1.0" />
                    
Directory.Packages.props
<PackageReference Include="Cmsql" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Cmsql --version 1.1.0
                    
#r "nuget: Cmsql, 1.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Cmsql@1.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Cmsql&version=1.1.0
                    
Install as a Cake Addin
#tool nuget:?package=Cmsql&version=1.1.0
                    
Install as a Cake Tool

CMSQL - CMS Query Language

CMSQL (CMS Query Language) is a DSL specifically designed to query over tree structured data/content in Content Management Systems. At this point there is only an implementation for the Optimizely CMS available which should be considered as a Proof Of Concept.

At this point the CMS Query Language is very minimalistic and offers basic query capabilities.

Goal

CMSQL is trying to answer questions like "Can you show me all news articles created by mr. X" or "Can you show me all product pages in category X" et cetera. It tries to answer such question by means of a simple easy to learn query language. It was designed with content management systems in mind that work with content types and which structure their site content in a hierarchical way, for example systems like Umbraco or Optimizely CMS.

The initial idea is that content-editors and developers should have a simple and easy to learn query language under their fingers available to quickly get that information they are looking for and probably want to edit, especially in large websites with huge content trees. The query language can be exposed to content-editors through some sort of editor in the CMS backend system.

Getting started

On its own the Cmsql package can parse Cmsql queries but it needs a specific implementation to execute them. You can use this package on itself if your project needs a Cmsql parser or if you're working on a specific implementation for Cmsql.

Installation

You can install the NuGet package by running the following command.

dotnet add package Cmsql --version 1.0.0

Usage

The Cmsql package contains a CmsqlQueryService which is basically a facade that takes care of parsing and executing queries through the ExecuteQuery method. The ExecuteQuery method returns an instance of CmsqlQueryResultSet which is a composite type that contains information about the parsing and execution process. When no errors are encountered and data is found the result set should contain data in the form of a collection of ICmsqlQueryResult.

The following (Optimizely CMS specific) example demonstrates how to execute a query, check for errors and get data from the result set.

var resultSet = _cmsqlQueryService.ExecuteQuery("select ProductPage from start where PageName = 'Alloy Plan'");
if (resultSet.IsSuccess)
{
  var pages = resultSet.GetResults()
    .OfType<PageDataCmsqlQueryResult>()
    .Select(p => p.Page)
    .ToList();
}

The query syntax

A query exists out of three parts, illustrated by the following grammar:

select <CONTENT-TYPE> from <STARTING-POINT> [where <PROPERTY CONDITIONS>][;]

Multiple queries can be parsed and run in one go when separated by a semicolon ;.

  • <CONTENT-TYPE>: A content type (for now you can only query/search for one specific type). This is nothing more than a string literal, for example common things like: ProductPage, NewsDetailPage, BlogPage etc.
  • <STARTING-POINT>: A starting point in the content tree to start searching from. A starting point can be any of the following three values:
    • root: This indicates that a query should start at the root node in the content-tree.
      • Example: select NewsDetailPage from root
    • start: This indicates that a query should start at the root/start node of the current website.
      • Example: select ProductCategoryPage from start
    • Integer identifier: This can be any number (integer) as long as it matches the ID of some node in the content tree, examples are 123, 2118, 78645.
      • Example: select BlogPage from 2118
  • <PROPERTY CONDITIONS>: A set of conditions/criteria. Conditions on itself exist out of three parts and have the following structure: <PROPERTY-NAME> <OPERATOR> <VALUE>.
    • <PROPERTY-NAME>: A property name that should exist on the given <CONTENT-TYPE>. This is a string literal, examples are Author, PageName, PublishedDate.
    • <OPERATOR>: Operators take any of the following forms:
      • = (Equals)
      • != (Not equals)
      • > (Greater than)
      • < (Less than)
      • >= (Greater than or equals)
      • <= (Less than or equals)
    • <VALUE>: A string literal.

Examples

  • select test from start where foo = 'bar'
  • select test from root where foo = 'bar'
  • select test from 12345 where foo = 'bar'
  • select test from 12345 where (foo = 'bar')
  • select test from 12345 where foo = 'bar' and foo = 'bar';
  • select test from 12345 where foo = 'bar' or foo = 'bar';
  • select test from 12345 where (foo = 'bar' and foo = 'bar');
  • select test from 12345 where (foo = 'bar' or foo = 'bar');
  • select test from 12345 where (foo = 'bar' and foo = 'bar') or (foo = 'bar' and foo = 'bar');
  • select test from 12345 where (foo = 'bar' and foo = 'bar') and (foo = 'bar' and foo = 'bar')
  • select test from 12345 where ((foo = 'bar' and foo = 'bar') and (foo = 'bar' and foo = 'bar'))
  • select test from start;select foo from root where name = 'test'
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Cmsql:

Package Downloads
Cmsql.EpiServer

This package contains the EPiServer CMSQL specific implementation.

Cmsql.Optimizely

Optimizely/EPiServer CMS integration for Cmsql query language.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.0 169 3/28/2026
1.0.0 136 1/13/2026
1.0.0-alpha2 1,355 5/25/2018
1.0.0-alpha1 1,469 3/13/2018