Skip to content

Cmsql.EpiServer is an EpiServer specific implementation for CMSQL.

License

Notifications You must be signed in to change notification settings

rbaarda/Cmsql.EpiServer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cmsql.EpiServer

This is the EpiServer specific implementation for the CMSQL - CMS Query Language. Please see the CMSQL repository for specifics on the CMS Query Language.

Please note that this project is a POC and is still in alpha phase.

Getting started

On its own the Cmsql package can parse Cmsql queries but it needs a specific implementation to execute them. This is the EPiServer specific implementation which uses the IPageCriteriaQueryService at its core. You could say this implementation exposes the IPageCriteriaQueryService through the query language.

Installation

You can install the NuGet package by running the following command (Please note that this is a pre-release).

Install-Package Cmsql.EpiServer -Version 1.0.0-alpha2

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 (EPiServer 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.ParseResult.Errors.Any() && !resultSet.ExecutionResult.Errors.Any())
{
  var pages = resultSet.ExecutionResult.QueryResults
    .OfType<PageDataCmsqlQueryResult>()
    .Select(p => p.Page)
    .ToList();
}

Setup

The CmsqlQueryService needs to be given an instance of a ICmsqlQueryRunner through its constructor when instantiated. The specific ICmsqlQueryRunner implementation for this package is PageCriteriaQueryRunner. You are free to set this up yourself by for example StructureMap, this could look something like the following in your StructureMap configuration: x.For<ICmsqlQueryRunner>().Use<PageCriteriaQueryRunner>();

Limitations

Since the Cmsql.EpiServer package revolves around the IPageCriteriaQueryService it is also limited by it. For now, querying is limited to Pages (PageData) only, and one PageType per query.

For now, only the following operators are supported in query criteria:

  • = (Equals)
  • > (Greater than)
  • < (Less than)
  • != (Not equals)

About

Cmsql.EpiServer is an EpiServer specific implementation for CMSQL.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages