HasMany:空列表而不是 null
我正在使用 CastleProject ActiveRecord。 我的类中有以下属性:
[HasMany(typeof(Order), Table = "Orders", ColumnKey = "OrderId")]
internal IList<Order> Orders
{
get;
set;
}
如果 Orders 表不包含任何订单,则 Orders 属性为 null。我可以以某种方式指出 ActiveRecord 它应该创建空列表而不是返回 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 autoproperty?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不完全是你想要的,但你不能在构造函数中实例化一个空列表:
Not exactly what you want, but couldn't you instantiate an empty list in the constructor: