A simple Entity
A simple entity can be expressed by the following code:
E# v2.0
using NBusiness.Templates;
family Business
{
entity Simple as EntityBase
{
field auto id int Sid;
field string Data;
}
}
Generated
using System;
using System.Data;
using NBusiness.Data;
namespace Business
{
public partial class Simple : EntityBase
{
private int _Sid;
public int Sid { /* ... */ }
private string _Data;
public string Data { /* ... */ }
//Various data access factories and rule initialization methods.
}
}
Usage (C#)
[Test]
private void SimpleEntityExample()
{
Simple s = Simple.CreateNew();
s.Data = "a simple example";
s.Save();
Assert.IsTrue(s.Sid > 0); //The id is auto assigned after the first time it is saved.
Assert.IsFalse(s.IsNew);
}
Here is an example of a
more complex entity.
Next:
Creating relationships