开发者

HasMany: Empty list instead of null

开发者 https://www.devze.com 2022-12-20 16:50 出处:网络
I am using CastleProject ActiveRecord. I have the following property in my class: [HasMany(typeof(Order), Table = \"Orders\", ColumnKey = \"OrderId\")]

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>();
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号