コード例 #1
0
        /// <summary>
        /// 设置UpdateSql的更新数据列。
        /// </summary>
        /// <param name="updateSql">UpdateSql对象。</param>
        /// <param name="context">Sql构造上下文信息。</param>
        protected virtual void HandlingUpdateFields(UpdateSqlStatement updateSql, SqlBuildingContext context)
        {
            var dataContext = context.DataContext.GetCurrentDataContextItem(context.Node.ID);

            if (dataContext == null || dataContext.Data == null || dataContext.Data.Count == 0)
            {
                updateSql = null;
                return;
            }
            if (updateSql.SqlBuildingInfo.CurrentSqlTable == null)
            {
                var tableName = context.TableName;
                updateSql.SqlBuildingInfo.CurrentSqlTable =
                    base.TryFindAndRegistSqlTable(tableName, tableName, tableName, tableName, updateSql.SqlBuildingInfo);
            }

            foreach (string dataItem in dataContext.Data.Keys)
            {
                var updateElement = context.Node.Elements.FirstOrDefault(i => i.ID == dataItem);
                var updateColumn  = context.DataObject.Columns.FirstOrDefault(i => i.ID == updateElement.ID);

                //字段设置
                var field = new UpdateField();
                field.IsUseFieldPrefix = false;
                field.IsUseVarBinding  = true;
                field.Table            = updateSql.SqlBuildingInfo.CurrentSqlTable;
                field.FieldName        = updateColumn.ColumnName;
                updateSql.UpdateFields.ChildCollection.Add(field);

                //字段值设置
                var fieldValue = new UpdateValue();
                fieldValue.Value = dataContext.Data[dataItem];
                updateSql.UpdateValues.ChildCollection.Add(fieldValue);
            }
        }
コード例 #2
0
        public override void ToXml(SqlElement sqlElement, XmlElement xmlParent)
        {
            base.ToXml(sqlElement, xmlParent);

            UpdateSqlStatement updateSql       = sqlElement as UpdateSqlStatement;
            XmlElement         xmlUpdateFields = SerializerUtil.AddElement(xmlParent, UpdateFieldList.UPDATEFIELDLIST);

            updateSql.UpdateFields.ToXml(updateSql.UpdateFields, xmlUpdateFields);

            XmlElement xmlUpdateCondition = SerializerUtil.AddElement(xmlParent, UPDATECONDITION);

            updateSql.UpdateCondition.ToXml(updateSql.UpdateCondition, xmlUpdateCondition);
        }
コード例 #3
0
        public override void FromXml(SqlElement sqlElement, XmlElement xmlParent, XmlNamespaceManager xnm)
        {
            base.FromXml(sqlElement, xmlParent, xnm);

            UpdateSqlStatement updateSql = sqlElement as UpdateSqlStatement;
            ParserUtil         util      = new ParserUtil(xnm);

            XmlElement xmlUpdateFields = util.Child(xmlParent, UpdateFieldList.UPDATEFIELDLIST);

            updateSql.UpdateFields.FromXml(updateSql.UpdateFields, xmlUpdateFields, xnm);

            XmlElement xmlUpdateCondition = util.Child(xmlParent, UPDATECONDITION);

            updateSql.UpdateCondition.FromXml(updateSql.UpdateCondition, xmlUpdateCondition, xnm);
        }
コード例 #4
0
        /// <summary>
        /// 解析外部传入的过滤条件。
        /// </summary>
        /// <param name="context">SQL构造上下文信息。</param>
        /// <param name="currentObject">主键过滤条件对应的GSPNode。</param>
        /// <param name="dataObject">主键过滤条件对应的GSPDataTable。</param>
        /// <param name="sqlInfo">SQL拼装的中间变量。</param>
        /// <returns>解析后的过滤条件。</returns>
        protected void GetUpdateSqlCondition(UpdateSqlStatement sql, SqlBuildingContext context, DomainObject currentObject, DataObject dataObject)
        {
            //若是非主键形式条件定义。
            if (context.IsUseCondition)
            {
                var condition = this.GetOrdinaryCondition(context, sql.SqlBuildingInfo);
                if (condition != null)
                {
                    sql.UpdateCondition.ChildCollection.Add(condition);
                }
            }

            //若是根据主键值,则获取主键值条件Sql语句。
            var sqlPrimaryKey = this.GetPrimaryKeyCondition(context, currentObject, dataObject, sql.SqlBuildingInfo);

            if (sqlPrimaryKey != null)
            {
                sql.UpdateCondition.ChildCollection.Add(sqlPrimaryKey);
            }
        }
コード例 #5
0
 /// <summary>
 /// 构造UpdateSql的过滤条件。
 /// </summary>
 /// <param name="sql">Sql语句对象。</param>
 /// <param name="context">Sql构造上下文信息。</param>
 private void HandlingConditionInfoAddData(UpdateSqlStatement sql, SqlBuildingContext context)
 {
     base.GetUpdateSqlCondition(sql, context, context.Node, context.DataObject);
 }