View on GitHub

SauceDB

.net ORM with multipe database engine support.

Download this project as a .zip file Download this project as a tar.gz file

Object Initialization

In order for this to work you define a method on the object (private or public dont matter)
This method can either have no arguments or one argument of type IDataStore

Method One

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DataAccess.Core.Attributes;

namespace SauceExample
{
  public class MyObject
  {
    public int id { get; set; }

    [DataField(DefaultValue="Bob")]
    public string Name { get; set; }

    [IgnoredField]
    public int Length { get; set; }
    
    [AdditionalInit]
    public void CallMeWhenLoaded()
    {
      Length = Name.Length;
    }
  }
}

Method Two

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DataAccess.Core.Attributes;

namespace SauceExample
{
  public class MyObject
  {
    public int id { get; set; }

    [DataField(DefaultValue="Bob")]
    public string Name { get; set; }

    [IgnoredField]
    public int Length { get; set; }
    
    [AdditionalInit]
    public void CallMeWhenLoaded(IDataStore foo)
    {
       //foo is the dstore that loaded the object
       //do whatever with it
    }
  }
}