Beispiel #1
0
        public EntityAction Update(object persisted, object updated, DatabaseParameterHandler parameters = null)
        {
            this.OnUpdating(updated);
            var update = default(IDatabaseQuery);

            if (!this.GetUpdateQuery(persisted, updated, out update))
            {
                return(EntityAction.None);
            }
            if (parameters == null)
            {
                parameters = new ParameterHandlerStrategy(this.Table, updated).Handler;
            }
            var count = this.Database.Execute(update, parameters, this.Transaction);

            if (count != 1)
            {
                this.OnConcurrencyViolation(updated);
            }
            else
            {
                this.OnUpdated(updated);
            }
            return(EntityAction.Updated);
        }
Beispiel #2
0
        public EntityAction Add(object item, DatabaseParameterHandler parameters = null)
        {
            this.OnAdding(item);
            var add = this.Database.QueryCache.Add(this.Table);

            if (parameters == null)
            {
                parameters = new ParameterHandlerStrategy(this.Table, item).Handler;
            }
            var key = this.Database.ExecuteScalar <object>(add, parameters, this.Transaction);

            this.OnAdded(key, item);
            return(EntityAction.Added);
        }
Beispiel #3
0
        public EntityAction Delete(object item, DatabaseParameterHandler parameters = null)
        {
            var delete = this.Database.QueryCache.Delete(this.Table);

            if (parameters == null)
            {
                parameters = new ParameterHandlerStrategy(this.Table, item).Handler;
            }
            var count = this.Database.Execute(delete, parameters, this.Transaction);

            if (count != 1)
            {
                this.OnConcurrencyViolation(item);
            }
            else
            {
                this.OnDeleted(item);
            }
            return(EntityAction.Deleted);
        }