CascadeCore 1.0.7

System for in-memory datastore cascading and foreign key relations.

Install-Package CascadeCore -Version 1.0.7
dotnet add package CascadeCore --version 1.0.7
<PackageReference Include="CascadeCore" Version="1.0.7" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add CascadeCore --version 1.0.7
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: CascadeCore, 1.0.7"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install CascadeCore as a Cake Addin
#addin nuget:?package=CascadeCore&version=1.0.7

// Install CascadeCore as a Cake Tool
#tool nuget:?package=CascadeCore&version=1.0.7
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Cascade

A system for in-memory datastore cascading and foreign key relations.

Currently only supports HashSet<T> when using datastore-features.

What can you do with Cascade?

By giving your POCO-types an [PrimaryKey]-attribute as well as [ForeignKey(typeof(Parent)] Cascade creates an easy to use relation between these objects when storing these objects in a IDataStore.

Example usage

public class Parent : ICascadable
{
    [PrimaryKey]
    public int Id { get; set; }
}

public class Child : ICascadable
{
    [PrimaryKey]
    public int Id { get; set; }
    
    [ForeignKey(typeof(Parent), delete: CascadeMode.Cascade)]
    public int ParentId { get; set; }
}

public class Store
{
    public HashSet<Parent> Parents { get; set; }
    
    public HashSet<Child> Children { get; set; }
}

...

static void Main()
{
    var store = new Store()
    {
        Parents = new HashSet<Parent>(),
        Children = new HashSet<Child>(),
    };
    
    store.Parents.Add(new Parent() { Id = 1 });
    store.Children.Add(new Child() { Id = 1, ParentId = 1 });
    store.Children.Add(new Child() { Id = 2, ParentId = 1 });
    store.Children.Add(new Child() { Id = 3, ParentId = 2 });
    store.Children.Add(new Child() { Id = 4, ParentId = 2 });
    
    CascadeCoreBuilder
        .Create()
        .WithStore(store)
        .Register();

    //Will cascade-delete all Children which references this primary key.
    CascadeCore.Instance.EventHandler.DeleteEntity(new Parent() { Id = 1 });
}

Future work

  • SQL-generator for foreign keys.
  • Fully support all types of cascading.
  • More?

Cascade

A system for in-memory datastore cascading and foreign key relations.

Currently only supports HashSet<T> when using datastore-features.

What can you do with Cascade?

By giving your POCO-types an [PrimaryKey]-attribute as well as [ForeignKey(typeof(Parent)] Cascade creates an easy to use relation between these objects when storing these objects in a IDataStore.

Example usage

public class Parent : ICascadable
{
    [PrimaryKey]
    public int Id { get; set; }
}

public class Child : ICascadable
{
    [PrimaryKey]
    public int Id { get; set; }
    
    [ForeignKey(typeof(Parent), delete: CascadeMode.Cascade)]
    public int ParentId { get; set; }
}

public class Store
{
    public HashSet<Parent> Parents { get; set; }
    
    public HashSet<Child> Children { get; set; }
}

...

static void Main()
{
    var store = new Store()
    {
        Parents = new HashSet<Parent>(),
        Children = new HashSet<Child>(),
    };
    
    store.Parents.Add(new Parent() { Id = 1 });
    store.Children.Add(new Child() { Id = 1, ParentId = 1 });
    store.Children.Add(new Child() { Id = 2, ParentId = 1 });
    store.Children.Add(new Child() { Id = 3, ParentId = 2 });
    store.Children.Add(new Child() { Id = 4, ParentId = 2 });
    
    CascadeCoreBuilder
        .Create()
        .WithStore(store)
        .Register();

    //Will cascade-delete all Children which references this primary key.
    CascadeCore.Instance.EventHandler.DeleteEntity(new Parent() { Id = 1 });
}

Future work

  • SQL-generator for foreign keys.
  • Fully support all types of cascading.
  • More?

NuGet packages (1)

Showing the top 1 NuGet packages that depend on CascadeCore:

Package Downloads
CascadeCore.SQL
Helpers for generating DDL for various databases when using CascadeCore.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
1.0.7 218 11/26/2019
1.0.2 204 11/20/2019
1.0.1 209 11/17/2019
1.0.0 196 11/15/2019