Ejemplo n.º 1
0
        /// <summary>
        /// Updates the existing entry within the table using the primaryField
        /// </summary>
        protected virtual void update(bool overwritePrimaryKey = false)
        {
            var q = new Query.Update(__tbl, new Where.Equals(__pkyc, this[__pkyn]));

            foreach (var field in __def.fields.Values)
            {
                if (field.primary && !overwritePrimaryKey)
                {
                    continue;
                }
                q.addValue(field.column, RowWriter.write(field.type, this[field.name]));
            }
            __db.exec(q);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Inserts this object's data into the table as a new row.
        /// </summary>
        protected virtual void insert()
        {
            var q = new Query.Insert(__tbl);

            q.output(__pkyc);
            foreach (var field in __def.fields.Values)
            {
                if (field.primary)
                {
                    continue;
                }
                q.addValue(field.column, RowWriter.write(field.type, this[field.name]));
            }
            var r = __db.scalar(q);

            this[__pkyn] = r;
        }