Пример #1
0
        public T SaveOrUpdate(T target)
        {
            return(TryCatch(() =>
            {
                var enlist = new Db4oEnlist(sessionManager.Session, target);
                bool inTransaction = Enlist(enlist);
                sessionManager.Session.Store(target);
                if (!inTransaction)
                {
                    sessionManager.Session.Commit();
                }

                return target;
            }));
        }
Пример #2
0
        public void Delete(T target)
        {
            if (target == null)
            {
                return; // Silently fail.
            }
            TryCatch(() =>
            {
                if (!sessionManager.Session.Ext().IsActive(target))
                {
                    target = Get(target.Id);
                }

                var enlist        = new Db4oEnlist(sessionManager.Session, target);
                var inTransaction = Enlist(enlist);
                sessionManager.Session.Delete(target);

                if (!inTransaction)
                {
                    sessionManager.Session.Commit();
                }
                return(null);
            });
        }