Example #1
0
        public int Update(Expression <Func <object> > expression)
        {
            HashSet <string> props = ExpressionHelper.GetExpression_PropertyList(expression);

            if (props.Count == 0)
            {
                throw new ObjectMappingException("not any property updated!");
            }

            object obj     = expression.Compile()();
            Type   objType = obj.GetType();

            foreach (var prop in props)
            {
                var           val    = objType.GetProperty(prop).GetValue(obj, null);
                ColumnMapping column = TableMapping.GetColumnMappingByProperty(prop);
                this.UpdateParameters.Add(new SqlParameter(column != null ? column.Name : prop, val));
            }

            DatabaseEngine db = DatabaseEngineFactory.GetDatabaseEngine();

            return(db.Update(this));
        }
Example #2
0
        public int Update()
        {
            DatabaseEngine db = DatabaseEngineFactory.GetDatabaseEngine();

            return(db.Update(this));
        }