HasMany: Empty list instead of null
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 autoprope开发者_StackOverflow中文版rty?
Not exactly what you want, but couldn't you instantiate an empty list in the constructor:
public MyClass()
{
Orders = new List<Order>();
}
精彩评论