这是我的代码:
var Operations = new List<Operation>
{
new Operation
{
Date = DateTime.Now,
OperationId = 0,
OperationType = OperationType.Entry,
OperationVehicles = new List<OperationVehicle>
{
new OperationVehicle { Vehicle = vehicle},
}
},
new Operation
{
Date = DateTime.Now.AddDays(2),
OperationId = 1,
OperationType = OperationType.Exit,
OperationVehicles = new List<OperationVehicle>
{
new OperationVehicle { Vehicle = vehicle, /* Operation = ???*/},
}
}
};
OperationVehicle
类有一个类型的虚拟公共属性Operation
,我想在这个阶段用它的父操作实例实例化它。好吧,我认为此时操作可能尚未创建。有没有办法在 C# 中做到这一点,还是我必须做经典的做作?