예제 #1
0
        private CPQuery GetUpdateQueryCommand()
        {
            IEntityProxy proxy = this as IEntityProxy;

            if (proxy == null)
            {
                throw new InvalidOperationException("请在调用BeginEdit()的返回值对象上调用Update方法。");
            }

            // 获取数据实体对象的主键值,如果数据实体没有指定主键,将会抛出一个异常
            Tuple <string, object> rowKey = proxy.GetRowKey();

            CPQuery update = GetUpdateQuery(rowKey);

            if (update == null)
            {
                return(null);
            }

            CPQuery query = update
                            + " WHERE " + rowKey.Item1 + " = " + new QueryParameter(rowKey.Item2);

            proxy.ClearChangeFlags();              // 清除修改标记,防止多次调用

            return(query);
        }