Example #1
0
        public void Update(IStorageObject obj)
        {
            DbEventArgs args;

            if (obj.ModifiedValues.Count != 0)
            {
                string[] strArray  = obj.ModifiedValues.Keys.ToArray <string>();
                string   updateSQL = this.SqlFormatter.GetUpdateSQL(obj);
                Debug.WriteLine("GetUpdateSQL: " + updateSQL);
                this.DbOperator.ExecuteNonQuery(updateSQL);
                Action item = delegate
                {
                    args = new DbEventArgs(this, DbOperationAction.Update);
                    obj.OnWrote(this, args);
                };
                if (this.DbOperator.IsBeginTransaction)
                {
                    this.transActions.Add(item);
                }
                else
                {
                    item();
                }
            }
        }
Example #2
0
        public void Insert(IStorageObject obj)
        {
            DbEventArgs         args;
            string              insertSQL = this.SqlFormatter.GetInsertSQL(obj);
            Type                type      = obj.GetType();
            int                 num       = this.DbOperator.ExecuteScalar <int>(insertSQL);
            DynamicPropertyInfo autoIncrementDynamicPropertyInfo = DbObjectTools.GetAutoIncrementDynamicPropertyInfo(DbObjectTools.GetDbObjectInfo(type));

            if ((autoIncrementDynamicPropertyInfo != null) & (num != 0))
            {
                obj.SetValue(autoIncrementDynamicPropertyInfo.PropertyName, num);
            }
            Action item = delegate
            {
                args = new DbEventArgs(this, DbOperationAction.Insert);
                obj.OnWrote(this, args);
            };

            if (this.DbOperator.IsBeginTransaction)
            {
                this.transActions.Add(item);
            }
            else
            {
                item();
            }
        }
Example #3
0
        public void Delete(IStorageObject obj)
        {
            string deleteSQL = this.SqlFormatter.GetDeleteSQL(obj);

            this.DbOperator.ExecuteNonQuery(deleteSQL);
            DbEventArgs e = new DbEventArgs(this, DbOperationAction.Delete);

            obj.OnWrote(this, e);
        }