views:

80

answers:

1

I am using CastleProject ActiveRecord. I have the following property in my class:

[HasMany(typeof(Order), Table = "Orders", ColumnKey = "OrderId")]
internal IList<Order> Orders
{
  get;
  set;
}

In case Orders table does not contain any orders, Orders property is null. Can I somehow point ActiveRecord that it should create empty list instead of returning null, without giving up autoproperty?

A: 

Not exactly what you want, but couldn't you instantiate an empty list in the constructor:

public MyClass()
{
  Orders = new List<Order>();
}
M4N

related questions