Rochas.SqlWrapper 1.5.0

dotnet add package Rochas.SqlWrapper --version 1.5.0
                    
NuGet\Install-Package Rochas.SqlWrapper -Version 1.5.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="Rochas.SqlWrapper" Version="1.5.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Rochas.SqlWrapper" Version="1.5.0" />
                    
Directory.Packages.props
<PackageReference Include="Rochas.SqlWrapper" />
                    
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 Rochas.SqlWrapper --version 1.5.0
                    
#r "nuget: Rochas.SqlWrapper, 1.5.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 Rochas.SqlWrapper@1.5.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=Rochas.SqlWrapper&version=1.5.0
                    
Install as a Cake Addin
#tool nuget:?package=Rochas.SqlWrapper&version=1.5.0
                    
Install as a Cake Tool

Rochas.SqlWrapper

English | Português | Español | Deutsch | Français


English

Rochas.SqlWrapper is the multi-dialect SQL translation layer shared by the Rochas components (Rochas.DapperRepository, Rochas.BWOQ).

It concentrates all the logic that converts entity models (Poco / Anaemic Model) into ANSI SQL statements for the MySQL, SQL Server, PostgreSQL and SQLite dialects — including attribute mapping, LIKE filters, value ranges (RangeFilter), aggregations, pagination, relations and entity composition. Both the ToSql() method of BWOQ and the DapperRepository ORM rely on this package as their single translation layer.

The package targets netstandard2.1 and is published on NuGet.

Installation

dotnet add package Rochas.SqlWrapper

Main classes

EntitySqlParser      --> Parses entities into ANSI SQL (CRUD, query, count, paginated)
EntityReflector      --> Reflection/metadata of entities with thread-safe caches
Helpers.SQL.*        --> SQL statement constants/templates per dialect
Exceptions           --> Domain exceptions of the layer (e.g. PropertyNotListableException)

EntityReflector also exposes the reflection helpers shared with Rochas.BWOQ, all cached thread-safely by type:

GetObjectProps(object, params object[] filter)       --> Cached property list, optional name/path filter
GetObjectPropValues(object, PropertyInfo[])          --> Property values of an instance
GetTypedValue(Type, object)                          --> Converts raw value (DBNull/string) to the target type
InitNullComposition(object)                          --> Initializes null same-namespace class properties
CloneObjectData(object, object)                      --> Copies property values between instances
CloneObjectData<T>(object)                           --> Creates a new typed instance copying values
getObjectChilds(object)                              --> Same-namespace child instances (internal)

How to use

Define a model using the annotations of Rochas.Data.Specification:

using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Rochas.Data.Specification.Annotations;

[Table("sample_entity")]
public class SampleEntity
{
    [Key]
    [Column("id")]
    [AutoGenerated]
    public int Id { get; set; }

    [Column("doc_number")]
    public long DocNumber { get; set; }

    [Filterable]
    [Column("name")]
    public string Name { get; set; }

    [Column("creation_date")]
    public DateTime CreationDate { get; set; }
}

Parse the entity into a SQL statement for the desired dialect:

using Rochas.SqlWrapper.Helpers;
using Rochas.Data.Specification.Enums;

var filter = new SampleEntity { Name = "roberto" };

var sql = EntitySqlParser.ParseEntity(filter, DatabaseEngine.SQLite,
                                      PersistenceAction.Query, filter);

Paged queries use ParseEntityPaged, which appends the correct pagination clause (LIMIT/OFFSET or OFFSET ... ROWS FETCH NEXT ... ROWS ONLY) for each engine:

var pagedSql = EntitySqlParser.ParseEntityPaged(filter, DatabaseEngine.PostgreSQL,
                                                PersistenceAction.Query, filter,
                                                offset: 10, pageSize: 20);

Requires the annotations of Rochas.Data.Specification ([Table], [Key], optional [Column] — without [Table] the class name is used, [Key] is mandatory).

Multi-database support

Feature MySQL SQL Server PostgreSQL SQLite
LIMIT/pagination Yes OFFSET FETCH/TOP Yes Yes
Booleans 1/0 1/0 TRUE/FALSE 1/0
Identifier quoting "column"

License

Licensed under the GNU GPL v2 license.


Português

Rochas.SqlWrapper é a camada de tradução SQL multi-dialeto compartilhada pelos componentes Rochas (Rochas.DapperRepository, Rochas.BWOQ).

Ela concentra toda a inteligência de conversão de entidades (Poco / Anaemic Model) em instruções SQL ANSI para os dialetos MySQL, SQL Server, PostgreSQL e SQLite — incluindo paráfrase de atributos, filtros LIKE, intervalos de valores (RangeFilter), agregações, paginação, relações e composição de entidades. Tanto o método ToSql() do BWOQ quanto a ORM DapperRepository dependem deste pacote como camada única de tradução.

O pacote tem como alvo o netstandard2.1 e é publicado no NuGet.

Instalação

dotnet add package Rochas.SqlWrapper

Nome das Classes

EntitySqlParser      --> Parse de entidades para SQL ANSI (CRUD, consulta, count, paginado)
EntityReflector      --> Reflexão/metadata das entidades com caches thread-safe
Helpers.SQL.*        --> Constantes/templates de instruções SQL por dialeto
Exceptions           --> Exceções de domínio da camada (ex.: PropertyNotListableException)

O EntityReflector também expõe os helpers de reflexão compartilhados com o Rochas.BWOQ, todos com cache thread-safe por tipo:

GetObjectProps(object, params object[] filter)       --> Lista cacheada de propriedades, filtro opcional por nome/caminho
GetObjectPropValues(object, PropertyInfo[])          --> Valores das propriedades de uma instância
GetTypedValue(Type, object)                          --> Converte valor bruto (DBNull/string) para o tipo de destino
InitNullComposition(object)                          --> Inicializa propriedades nulas de classe do mesmo namespace
CloneObjectData(object, object)                      --> Copia valores de propriedades entre instâncias
CloneObjectData<T>(object)                           --> Cria uma nova instância tipada copiando valores
getObjectChilds(object)                              --> Instâncias filhas do mesmo namespace (interno)

Como usar

Defina um modelo usando as annotations de Rochas.Data.Specification:

using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Rochas.Data.Specification.Annotations;

[Table("sample_entity")]
public class SampleEntity
{
    [Key]
    [Column("id")]
    [AutoGenerated]
    public int Id { get; set; }

    [Column("doc_number")]
    public long DocNumber { get; set; }

    [Filterable]
    [Column("name")]
    public string Name { get; set; }

    [Column("creation_date")]
    public DateTime CreationDate { get; set; }
}

Faça o parse da entidade em uma instrução SQL para o dialeto desejado:

using Rochas.SqlWrapper.Helpers;
using Rochas.Data.Specification.Enums;

var filter = new SampleEntity { Name = "roberto" };

var sql = EntitySqlParser.ParseEntity(filter, DatabaseEngine.SQLite,
                                      PersistenceAction.Query, filter);

Consultas paginadas usam ParseEntityPaged, que anexa a cláusula de paginação correta (LIMIT/OFFSET ou OFFSET ... ROWS FETCH NEXT ... ROWS ONLY) para cada banco:

var pagedSql = EntitySqlParser.ParseEntityPaged(filter, DatabaseEngine.PostgreSQL,
                                                PersistenceAction.Query, filter,
                                                offset: 10, pageSize: 20);

Requer as annotations de Rochas.Data.Specification ([Table], [Key], [Column] opcional — sem [Table] usa o nome da classe, [Key] obrigatório).

Suporte a múltiplos bancos

Recurso MySQL SQL Server PostgreSQL SQLite
LIMIT/paginação Sim OFFSET FETCH/TOP Sim Sim
Booleanos 1/0 1/0 TRUE/FALSE 1/0
Quote de identificador "coluna"

Licença

Licenciado sob a licença GNU GPL v2.


Español

Rochas.SqlWrapper es la capa de traducción SQL multi-dialecto compartida por los componentes Rochas (Rochas.DapperRepository, Rochas.BWOQ).

Concentra toda la lógica de conversión de entidades (Poco / Anaemic Model) en sentencias SQL ANSI para los dialectos MySQL, SQL Server, PostgreSQL y SQLite — incluyendo el mapeo de atributos, filtros LIKE, rangos de valores (RangeFilter), agregaciones, paginación, relaciones y composición de entidades. Tanto el método ToSql() de BWOQ como el ORM DapperRepository dependen de este paquete como su única capa de traducción.

El paquete está dirigido a netstandard2.1 y se publica en NuGet.

Instalación

dotnet add package Rochas.SqlWrapper

Nombre de las clases

EntitySqlParser      --> Parseo de entidades a SQL ANSI (CRUD, consulta, count, paginado)
EntityReflector      --> Reflexión/metadata de las entidades con cachés thread-safe
Helpers.SQL.*        --> Constantes/plantillas de sentencias SQL por dialecto
Exceptions           --> Excepciones de dominio de la capa (ej.: PropertyNotListableException)

EntityReflector también expone los helpers de reflexión compartidos con Rochas.BWOQ, todos con caché thread-safe por tipo:

GetObjectProps(object, params object[] filter)       --> Lista cacheada de propiedades, filtro opcional por nombre/ruta
GetObjectPropValues(object, PropertyInfo[])          --> Valores de las propiedades de una instancia
GetTypedValue(Type, object)                          --> Convierte valor bruto (DBNull/string) al tipo de destino
InitNullComposition(object)                          --> Inicializa propiedades nulas de clase del mismo espacio de nombres
CloneObjectData(object, object)                      --> Copia valores de propiedades entre instancias
CloneObjectData<T>(object)                           --> Crea una nueva instancia tipada copiando valores
getObjectChilds(object)                              --> Instancias hijas del mismo espacio de nombres (interno)

Cómo usar

Defina un modelo usando las anotaciones de Rochas.Data.Specification:

using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Rochas.Data.Specification.Annotations;

[Table("sample_entity")]
public class SampleEntity
{
    [Key]
    [Column("id")]
    [AutoGenerated]
    public int Id { get; set; }

    [Column("doc_number")]
    public long DocNumber { get; set; }

    [Filterable]
    [Column("name")]
    public string Name { get; set; }

    [Column("creation_date")]
    public DateTime CreationDate { get; set; }
}

Parsear la entidad en una sentencia SQL para el dialecto deseado:

using Rochas.SqlWrapper.Helpers;
using Rochas.Data.Specification.Enums;

var filter = new SampleEntity { Name = "roberto" };

var sql = EntitySqlParser.ParseEntity(filter, DatabaseEngine.SQLite,
                                      PersistenceAction.Query, filter);

Las consultas paginadas usan ParseEntityPaged, que añade la cláusula de paginación correcta (LIMIT/OFFSET u OFFSET ... ROWS FETCH NEXT ... ROWS ONLY) para cada motor:

var pagedSql = EntitySqlParser.ParseEntityPaged(filter, DatabaseEngine.PostgreSQL,
                                                PersistenceAction.Query, filter,
                                                offset: 10, pageSize: 20);

Requiere las anotaciones de Rochas.Data.Specification ([Table], [Key], [Column] opcional — sin [Table] se usa el nombre de la clase, [Key] es obligatorio).

Soporte de múltiples bases de datos

Característica MySQL SQL Server PostgreSQL SQLite
LIMIT/paginación OFFSET FETCH/TOP
Booleanos 1/0 1/0 TRUE/FALSE 1/0
Delimitado de identificadores "columna"

Licencia

Licenciado bajo la licencia GNU GPL v2.


Deutsch

Rochas.SqlWrapper ist die mehrdialektfähige SQL-Übersetzungsschicht, die von den Rochas-Komponenten (Rochas.DapperRepository, Rochas.BWOQ) gemeinsam genutzt wird.

Sie bündelt die gesamte Logik zur Umwandlung von Entitätsmodellen (Poco / Anaemic Model) in ANSI-SQL-Anweisungen für die Dialekte MySQL, SQL Server, PostgreSQL und SQLite — einschließlich Attributzuordnung, LIKE-Filtern, Wertebereichen (RangeFilter), Aggregationen, Pagination, Beziehungen und Entitätskomposition. Sowohl die ToSql()-Methode von BWOQ als auch das ORM DapperRepository verlassen sich auf dieses Paket als ihre einzige Übersetzungsschicht.

Das Paket zielt auf netstandard2.1 ab und wird auf NuGet veröffentlicht.

Installation

dotnet add package Rochas.SqlWrapper

Wichtigste Klassen

EntitySqlParser      --> Parse von Entitäten zu ANSI-SQL (CRUD, Abfrage, Count, paginiert)
EntityReflector      --> Reflexion/Metadaten der Entitäten mit thread-sicheren Caches
Helpers.SQL.*        --> SQL-Anweisungs-Konstanten/Vorlagen je Dialekt
Exceptions           --> Domänen-Exceptions der Schicht (z. B. PropertyNotListableException)

EntityReflector stellt außerdem die mit Rochas.BWOQ geteilten Reflexions-Helfer bereit, alle thread-sicher pro Typ gecacht:

GetObjectProps(object, params object[] filter)       --> Gecachte Eigenschaftsliste, optionaler Name/Pfad-Filter
GetObjectPropValues(object, PropertyInfo[])          --> Eigenschaftswerte einer Instanz
GetTypedValue(Type, object)                          --> Konvertiert Rohwert (DBNull/string) zum Zieltyp
InitNullComposition(object)                          --> Initialisiert null-Eigenschaften von Klassen im selben Namespace
CloneObjectData(object, object)                      --> Kopiert Eigenschaftswerte zwischen Instanzen
CloneObjectData<T>(object)                           --> Erstellt eine neue typisierte Instanz durch Kopieren der Werte
getObjectChilds(object)                              --> Kind-Instanzen im selben Namespace (intern)

Verwendung

Definieren Sie ein Modell mit den Annotationen von Rochas.Data.Specification:

using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Rochas.Data.Specification.Annotations;

[Table("sample_entity")]
public class SampleEntity
{
    [Key]
    [Column("id")]
    [AutoGenerated]
    public int Id { get; set; }

    [Column("doc_number")]
    public long DocNumber { get; set; }

    [Filterable]
    [Column("name")]
    public string Name { get; set; }

    [Column("creation_date")]
    public DateTime CreationDate { get; set; }
}

Parsen Sie die Entität in eine SQL-Anweisung für den gewünschten Dialekt:

using Rochas.SqlWrapper.Helpers;
using Rochas.Data.Specification.Enums;

var filter = new SampleEntity { Name = "roberto" };

var sql = EntitySqlParser.ParseEntity(filter, DatabaseEngine.SQLite,
                                      PersistenceAction.Query, filter);

Für paginierte Abfragen wird ParseEntityPaged verwendet, das die korrekte Paginierungsklausel (LIMIT/OFFSET bzw. OFFSET ... ROWS FETCH NEXT ... ROWS ONLY) für jedes Datenbanksystem anhängt:

var pagedSql = EntitySqlParser.ParseEntityPaged(filter, DatabaseEngine.PostgreSQL,
                                                PersistenceAction.Query, filter,
                                                offset: 10, pageSize: 20);

Erfordert die Annotationen von Rochas.Data.Specification ([Table], [Key], optional [Column] — ohne [Table] wird der Klassenname verwendet, [Key] ist Pflicht).

Unterstützung mehrerer Datenbanken

Funktion MySQL SQL Server PostgreSQL SQLite
LIMIT/Pagination Ja OFFSET FETCH/TOP Ja Ja
Boolesche Werte 1/0 1/0 TRUE/FALSE 1/0
Identifikator-Quoting "Spalte"

Lizenz

Lizenziert unter der GNU-GPL-v2-Lizenz.


Français

Rochas.SqlWrapper est la couche de traduction SQL multi-dialecte partagée par les composants Rochas (Rochas.DapperRepository, Rochas.BWOQ).

Elle concentre toute la logique de conversion des modèles d'entités (Poco / Anaemic Model) en instructions SQL ANSI pour les dialectes MySQL, SQL Server, PostgreSQL et SQLite — y compris le mappage des attributs, les filtres LIKE, les plages de valeurs (RangeFilter), les agrégations, la pagination, les relations et la composition d'entités. Tant la méthode ToSql() de BWOQ que l'ORM DapperRepository s'appuient sur ce package comme unique couche de traduction.

Le package cible netstandard2.1 et est publié sur NuGet.

Installation

dotnet add package Rochas.SqlWrapper

Principales classes

EntitySqlParser      --> Parse d'entités en SQL ANSI (CRUD, requête, count, paginé)
EntityReflector      --> Réflexion/métadonnées des entités avec caches thread-safe
Helpers.SQL.*        --> Constantes/modèles d'instructions SQL par dialecte
Exceptions           --> Exceptions de domaine de la couche (ex. : PropertyNotListableException)

EntityReflector expose également les helpers de réflexion partagés avec Rochas.BWOQ, tous mis en cache thread-safely par type :

GetObjectProps(object, params object[] filter)       --> Liste d'propriétés en cache, filtre optionnel nom/chemin
GetObjectPropValues(object, PropertyInfo[])          --> Valeurs des propriétés d'une instance
GetTypedValue(Type, object)                          --> Convertit une valeur brute (DBNull/string) vers le type cible
InitNullComposition(object)                          --> Initialise les propriétés de classe null du même namespace
CloneObjectData(object, object)                      --> Copie les valeurs de propriétés entre instances
CloneObjectData<T>(object)                           --> Crée une nouvelle instance typée en copiant les valeurs
getObjectChilds(object)                              --> Instances enfants du même namespace (interne)

Comment utiliser

Définissez un modèle à l'aide des annotations de Rochas.Data.Specification :

using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Rochas.Data.Specification.Annotations;

[Table("sample_entity")]
public class SampleEntity
{
    [Key]
    [Column("id")]
    [AutoGenerated]
    public int Id { get; set; }

    [Column("doc_number")]
    public long DocNumber { get; set; }

    [Filterable]
    [Column("name")]
    public string Name { get; set; }

    [Column("creation_date")]
    public DateTime CreationDate { get; set; }
}

Analysez l'entité en une instruction SQL pour le dialecte souhaité :

using Rochas.SqlWrapper.Helpers;
using Rochas.Data.Specification.Enums;

var filter = new SampleEntity { Name = "roberto" };

var sql = EntitySqlParser.ParseEntity(filter, DatabaseEngine.SQLite,
                                      PersistenceAction.Query, filter);

Les requêtes paginées utilisent ParseEntityPaged, qui ajoute la clause de pagination correcte (LIMIT/OFFSET ou OFFSET ... ROWS FETCH NEXT ... ROWS ONLY) pour chaque moteur :

var pagedSql = EntitySqlParser.ParseEntityPaged(filter, DatabaseEngine.PostgreSQL,
                                                PersistenceAction.Query, filter,
                                                offset: 10, pageSize: 20);

Nécessite les annotations de Rochas.Data.Specification ([Table], [Key], [Column] optionnel — sans [Table], le nom de la classe est utilisé, [Key] est obligatoire).

Prise en charge multi-bases de données

Fonctionnalité MySQL SQL Server PostgreSQL SQLite
LIMIT/pagination Oui OFFSET FETCH/TOP Oui Oui
Booléens 1/0 1/0 TRUE/FALSE 1/0
Délimitation des identifiants "colonne"

Licence

Sous licence GNU GPL v2.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos 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 Rochas.SqlWrapper:

Package Downloads
Rochas.DapperRepository

A lightweight generic entities cacheable repository using Dapper

Rochas.BWOQ

Rochas BWOQ - BitWise Object Query for compact query composition

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.5.0 0 9/23/2026
1.4.9 124 9/21/2026
1.1.2 273 8/15/2026

v1.5.0 - [NEW] In-memory statement snapshot cache for Query/Count (shared across methods, capped); [FIX] duplicate grouped columns in SELECT without aggregates. v1.4.10 - [FIX] EntityReflector handles dotless/null namespaces (IndexOf -1/NRE). v1.4.8 - [FIX] GROUP BY with aggregates: SELECT with keys only (exact, case-insensitive match) + aggregate expressions, with AS alias when the column differs from the property (42803 on PostgreSQL; Dapper did not materialize the key). v1.4.6 - [FIX] ParseEntityPaged accepts groupAttributes (GROUP BY + aggregates in paged queries; rescue of the data-toolkit-init branch). v1.4.5 - [FIX] GroupBy with aggregates: SELECT with keys + expressions only. [PERF] EntityReflector with cache. [DOCS] README in 5 languages. Data.Specification reference via NuGet (1.6.3). v1.4.4 - Build/pack normalization. v1.0.0 - Parser/reflector extraction from DapperRepository 1.9.5.