praeclarum/sqlite-net — pull request #205 by daynin (2013-04-21 16:06:53+00:00)
Title: Implemented one2many relationship

The possibility to create objects to the relationship of "one to many". In the examples directory added an example that demonstrates this feature. All new functionality is tested.

Sample of classes with one2many relationship:

public class Customer
{
public Customer(string name, List orders)
{
this.Name = name;
this.Orders = orders;
}
public Customer ()
{

}

[PrimaryKey]
public int Id {get; set;}

public string Name {get; set;}

[One2Many(typeof(Order))]
public List Orders {get; set;}

public override string ToString()
{
return string.Format("CustomerId: {0} \t Name: {1}",Id,Name);
}
}

public class Order
{
public Order (string orderName, int customerId)
{
this.OrderName = orderName;
this.CustomerId = customerId;
}

public Order ()
{

}

[PrimaryKey]
public int Id {get; set;}

public string OrderName {get; set;}

[References(typeof(Customer))]
[OnUpdateCascade]
[OnDeleteCascade]
public int CustomerId {get; set;}

public override string ToString()
{
return string.Format("OrderId: {0} \t CustomerId: {1}",Id,CustomerId);
}
}