internal static Guid Save(Delivery delivery) { using (var client = DeliveryDBClient.Connect()) { Guid guid = delivery.Guid; if (guid != Guid.Empty) { // refer here for an explanation on what's going on: // http://stackoverflow.com/questions/5848990/retrieve-an-object-in-one-db4o-session-store-in-another-disconnected-scenario // Get an inactive reference, get its temp ID and bind the supplied object to it instead Delivery inactiveReference = DeliveryDB.Get(delivery.Guid, false, client); if (inactiveReference != null) { long tempDb4oID = client.Ext().GetID(inactiveReference); client.Ext().Bind(delivery, tempDb4oID); } } else { guid = Guid.NewGuid(); } // Try to store, and return new guid on success client.Store(delivery); return(guid); } }
// Statics // ============================= public static Delivery Get(Guid deliveryID, bool deep = true) { return(DeliveryDB.Get(deliveryID, deep)); }
public static Delivery Get(Guid deliveryID) { return(DeliveryDB.Get(deliveryID)); }