using System.Reflection;
using NUnit.Framework;
using ODX.Core;
using ODX.LazyUnitTester;
namespace Relations{
[Table]
public abstract class Person : Entity
{
public abstract string Name { get; set;}
public abstract IEntityList<Pet> Pets { get; }
}
[Table]
public abstract class Pet : Entity
{
public abstract string Name { get; set;}
public abstract Person Master { get; set; }
}
[TestFixture]
public class C02_Relations_1xN
{
[TestBody]
static void Main()
{
Session session = new Session();
session.RegisterAssembly(Assembly.GetExecutingAssembly());
session.Prepare();
Person john = session.Create<Person>();
john.Name = "John";
Pet cat = session.Create<Pet>();
cat.Name = "Molly";
Pet dog = session.Create<Pet>();
dog.Name = "Beethoven";
cat.Master = dog.Master = john;
LUT.WriteLine("{0} masters pets:", john.Name);
foreach ( Pet p in john.Pets )
LUT.WriteLine("\t{0}",p.Name);
}
[Test]
public void Test()
{
LUT.Execute(Main);
}
}
}
|