Skip to content
/ Qapper Public

Qapper (pronounced 'kwapper') is a super simple object mapper for kdb+\q

License

Notifications You must be signed in to change notification settings

dotnetq/Qapper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Qapper - .net Data Mapping tools for Q

GitHub license Nuget NuGet GitHub issues GitHub forks GitHub stars

Qapper (pronounced 'kwapper') is a super simple object mapper for kdb+/q modelled after Dapper

DISCLAIMER

IMPORTANT: The current state of this toolkit is PRE-ALPHA/Development. Please consider it version a foundational version. Many areas could be improved and change significantly while refactoring current code and implementing new features.

Introduction

Qapper assists a .net developer to easily push data into and retrieve data from a kdb database. Qapper automatically maps between object instances and table rows so that client side programming involves working with simple C# object instances further simplifying the interaction.

Getting Started

Install the NuGet package.

Example

Given a plain C# class decorated with QSchema attributes...

namespace Auth
{
    public class User
    {
        [Key]
        public string Id { get; set; }
        [Unique]
        public string Login { get; set; }
        public string Name { get; set; }
        public string Description { get; set; }

        // We'll store the various roles when we deserialize
        [Ignore] public string[] PrincipalIds { get; set; }
    }
}    

... and an active corresponding kdb+ database built with QSchema.SchemaBuilder, we can create an instance of the User class userInstance and store it in the database with:

    var entities = new Auth.User[]{userInstance};
    var qTable = QMapper.ConvertToQTable(entities);
    var tableName = SchemaBuilder.GetQTableName(typeof(Auth.User));
    connection.Sync("upsert", tableName, qTable);

Where the connection instance above is an active QConnection to a kdb+ database.

We can retrieve a collection of User objects from the database with a single line instruction:

IEnumerable<Auth.User> users = connection.QueryObjects<Auth.User>("select from .auth.user");

Qapper will automatically convert the returned 'q' table into an enumerable collection of object instances. The object properties of each object instance have been mapped to the columns of the table, using the QSchema naming convention, so each object instance will correspond to a row from the table. This will work with both keyed and unkeyed tables.

It really is that simple!

Take a look at the worked Example for more detail.

Future work will permit arbitrary mapping to pre-existing tables.

About

Qapper (pronounced 'kwapper') is a super simple object mapper for kdb+\q

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages