When there is an IsDeleted property defined on a class and it is true, the object will be deleted when the Save is called.
<TableMapping("OrderDetails")>
Public
Class OrderDetail
<PrimaryKey(PrimaryKeyType.Identity)>
Public
Property OrderDetailId() As Integer
<ParentObject(
"OrderId")>Public
Property Order() As Order
Public
Property Notes() As StringPublic
Property IsDirty() As BooleanPublic
Property IsDeleted() As BooleanEnd
Class
'Get the current instance of the helper
Private
db As IDataHelper = DataHelper.SessionFactory()
Private
order As New Order()Private
orderDetails As New List(Of OrderDetail)() From { New OrderDetail With {.Notes = "Order detail 1", .Order = order}, New OrderDetail With {.Notes = "Order detail 2", .Order = order}, New OrderDetail With {.Notes = "Order detail 3", .Order = order}}
order.OrderDetails = orderDetails
' Insert records
_dataHelper.SaveWithChildren(orderDetails)
orderDetails(1).Notes =
"Updated order detail 2"orderDetails(1).IsDirty =
TrueorderDetails(1).IsDeleted =
False
' Update second order detail
_dataHelper.Save(orderDetails)
orderDetails(1).IsDirty =
FalseorderDetails(1).IsDeleted =
True
' Delete second order detail
_dataHelper.Save(orderDetails)