using System;

using Sisyphus;
using Sisyphus.Department;
using Sisyphus.Impl;

namespace MyNameSpace {

  public class MyEntity : SpfEntity {

    public bool BoolField;
    public int IntField;
    public double DoubleField;
    public string StringField;
    public DateTime DateTimeField;

    public MyEntity() {
    }

  }

  public class MyEntityTest {

    public static void Main() {

      ISpfDataStore store = new SqlDataStore("localhost", "sisyphus", "sa", "");

      ISpfDataStoreBuilder storeBuilder = new SqlDataStoreBuilder(store);
      storeBuilder.CreateTable(typeof(MyEntity), true);

      MyEntity myEntity = new MyEntity();
      
      myEntity.BoolField = true;
      myEntity.IntField = 666;
      myEntity.DoubleField = 3.1415926;
      myEntity.StringField = "Hello SPF";
      myEntity.DateTimeField = DateTime.Now;

      ISpfDataStoreBroker broker = new SpfDataStoreBroker(store);

      broker.Persist(myEntity);

      MyEntity myRetrievedEntity = (MyEntity)broker.Retrieve(typeof(MyEntity), myEntity.Id);

      Console.WriteLine("myRetrievedEntity.StringField = '{0}'", myRetrievedEntity.StringField);

    }

  }

}