Skip to content
Marek Fišera edited this page Nov 28, 2015 · 14 revisions

Neptuo.Data.Sql is concept for simple and thin SQL data layer. Here are some thoughts on design. Implementation is currently far away.

Tables are described by TableColumns classes. These classes contains table, joined and computed columns.

Columns

Columns are key to everything. The base contract for column is:

public interface IColumn
{
    Type ValueType { get; }
}

and the generic version for specifying generic return type (for reading values, described later):

public interface IColumn<T> : IColumn
{ }

For these column contracts there are implementations for defining table owned column, left and inner joins, computed columns and etc.

Primary keys will be also marked own implementation of the IColumn. Inserts will defuse columns of this type, but updates will require those.

Joins

Having columns organized in TableColumns allows for great reuse in terms of joins. Define class with columns and create instance of it in the another TableColumns class to define join on the first table.

public class ProductColumns
{
    public TableColumn<int> Id { get; private set; }
    public TableColumn<string> Name { get; private set; }
}

public class OrderColumns
{
    public TableColumn<int> Id { get; private set; }
    public ProductProperties Product { get; private set; }
}

Clone this wiki locally