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 int OrderDetailId { get; set; }[
[ParentObject("OrderId")]
public Order Order { get; set; }
public string Notes { get; set; }
public bool IsDirty { get; set; }
public bool IsDeleted { get; set; }
}
//Get the current instance of the helper
IDataHelper db = DataHelper.SessionFactory();
Order order = new Order();
List<OrderDetail> orderDetails =
new List<OrderDetail>
{
new OrderDetail
{
"Order detail 1",Notes =
Order = order
},
new OrderDetail
{
"Order detail 2",Notes =
Order = order
},
new OrderDetail{
"Order detail 3",Notes =
Order = order
}
};
order.OrderDetails = orderDetails;
// Insert records
_dataHelper.SaveWithChildren(orderDetails);
orderDetails[1].Notes =
"Updated order detail 2";orderDetails[1].IsDirty =
true;orderDetails[1].IsDeleted =
false;
// Update second order detail
_dataHelper.Save(orderDetails);
orderDetails[1].IsDirty =
false;orderDetails[1].IsDeleted =
true;
// Delete second order detail
_dataHelper.Save(orderDetails);