/// <summary> /// 用XmlElement的信息构造SqlElement类的对象(或继承自SqlElement类的对象)。 /// </summary> /// <param name="sqlNode">SqlElement类的对象(或继承自SqlElement类的对象)</param> /// <param name="xmlParent">XmlDocument中的元素</param> /// <param name="xnm">集合命名空间范围管理类的对象</param> public virtual void FromXml(SqlElement sqlNode, XmlElement xmlParent, XmlNamespaceManager xnm) { ParserUtil util = new ParserUtil(xnm); XmlElement xmlId = util.Child(xmlParent, ID); XmlElement xmlVersion = util.Child(xmlParent, VERSION); //sqlNode.Id = xmlId.InnerText; //sqlNode.Version = xmlVersion.InnerText; XmlElement xmlChildList = util.Child(xmlParent, CHILDCOLLECTION); if (xmlChildList != null) { XmlNodeList childNodeList = util.Children(xmlChildList, SQLELEMENT); if (childNodeList != null) { sqlNode.CreateChildCollection(); foreach (XmlElement xmlChildNode in childNodeList) { //// 通过反射构造对象。 //string fullname = util.AttrStr(xmlChildNode, CLASSFULLNAME); //Assembly ass = Assembly.GetExecutingAssembly(); //SqlElement node = ass.CreateInstance(fullname) as SqlElement; int sqlElementType = util.AttrInt(xmlChildNode, SQLELEMENTTYPE); SqlElement node = SqlElementFactory.GetSQLElement(sqlElementType); node.FromXml(node, xmlChildNode, xnm); sqlNode.ChildCollection.Add(node); } } } }
/// <summary> /// 由XmlElement转换成SqlElement /// </summary> /// <param name="sqlElement">附加到的SqlElement</param> /// <param name="xmlParent">反序列化的XmlElement</param> /// <param name="xnm">命名空间</param> public override void FromXml(SqlElement sqlElement, XmlElement xmlParent, XmlNamespaceManager xnm) { base.FromXml(sqlElement, xmlParent, xnm); SubQuerySqlStatement selectSql = sqlElement as SubQuerySqlStatement; ParserUtil util = new ParserUtil(xnm); XmlElement xmlSelectList = util.Child(xmlParent, SelectFieldListStatement.SELECTLISTSTATEMENT); XmlElement xmlFrom = util.Child(xmlParent, From.FROM); XmlElement xmlJoinCondition = util.Child(xmlParent, JoinConditionStatement.JOINCONDITIONSTATEMENT); XmlElement xmlFilterCondition = util.Child(xmlParent, FILTERCONDITION); XmlElement xmlOrderByCondition = util.Child(xmlParent, ORDERBYCONDITION); selectSql.SelectList.FromXml(selectSql.SelectList, xmlSelectList, xnm); selectSql.From.FromXml(selectSql.From, xmlFrom, xnm); selectSql.JoinCondition.FromXml(selectSql.JoinCondition, xmlJoinCondition, xnm); selectSql.FilterCondition.FromXml(selectSql.FilterCondition, xmlFilterCondition, xnm); selectSql.OrderByCondition.FromXml(selectSql.OrderByCondition, xmlOrderByCondition, xnm); /* * MainFromItem只序列化,不反序列化。 * 其反序列化操作已包含在Froms的集合中,直接从集合中取即可。 * */ selectSql.mainFromItem = this.From.ChildCollection[0] as FromItem; }
public override void FromXml(SqlElement sqlElement, XmlElement xmlParent, XmlNamespaceManager xnm) { base.FromXml(sqlElement, xmlParent, xnm); JoinConditionItem joinConditionItem = sqlElement as JoinConditionItem; ParserUtil util = new ParserUtil(xnm); XmlElement xmlLeftField = util.Child(xmlParent, LEFTFIELD); joinConditionItem.LeftField.FromXml(joinConditionItem.LeftField, xmlLeftField, xnm); XmlElement xmlRightField = util.Child(xmlParent, RIGHTFIELD); joinConditionItem.RightField.FromXml(joinConditionItem.RightField, xmlRightField, xnm); }
public override void FromXml(SqlElement sqlElement, XmlElement xmlParent, XmlNamespaceManager xnm) { base.FromXml(sqlElement, xmlParent, xnm); LeftJoinItem leftJoinItem = sqlElement as LeftJoinItem; ParserUtil util = new ParserUtil(xnm); XmlElement xmlLeftJoinTable = util.Child(xmlParent, LEFTJOINTABLE); leftJoinItem.LeftJoinTable.FromXml(leftJoinItem.LeftJoinTable, xmlLeftJoinTable, xnm); XmlElement xmlAddtionalCondition = util.Child(xmlParent, ADDITIONALCONDITION); leftJoinItem.AdditionalCondition = xmlAddtionalCondition.InnerText; }
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); }
public override void FromXml(SqlElement sqlElement, XmlElement xmlParent, XmlNamespaceManager xnm) { base.FromXml(sqlElement, xmlParent, xnm); DeleteSqlStatement deleteSql = sqlElement as DeleteSqlStatement; ParserUtil util = new ParserUtil(xnm); XmlElement xmlCondition = util.Child(xmlParent, ConditionStatement.CONDITIONSTATEMENT); deleteSql.Condition.FromXml(deleteSql.Condition, xmlCondition, xnm); XmlElement xmlSubQuerySql = util.Child(xmlParent, SUBQUERYSQL); if (xmlSubQuerySql != null) { deleteSql.SubQuerySql = new SelectSqlForSubQuery(); deleteSql.SubQuerySql.FromXml(deleteSql.SubQuerySql, xmlSubQuerySql, xnm); } }
public override void FromXml(SqlElement sqlNode, XmlElement xmlParent, XmlNamespaceManager xnm) { base.FromXml(sqlNode, xmlParent, xnm); SqlStatement sqlStatement = sqlNode as SqlStatement; ParserUtil util = new ParserUtil(xnm); XmlElement xmlTableName = util.Child(xmlParent, TABLENAME); XmlElement xmlTableCode = util.Child(xmlParent, TABLECODE); XmlElement xmlCOID = util.Child(xmlParent, COMMONOBJECTID); XmlElement xmlNodeObjectID = util.Child(xmlParent, NODEOBJECTID); XmlElement xmlCOVersion = util.Child(xmlParent, COMMONOBJECTVERSION); XmlElement xmlNodeObjectVersion = util.Child(xmlParent, NODEOBJECTVERSION); sqlStatement.TableName = xmlTableName.InnerText; sqlStatement.TableCode = xmlTableCode.InnerText; sqlStatement.CommonObjectID = xmlCOID.InnerText; sqlStatement.NodeID = xmlNodeObjectID.InnerText; //sqlStatement.CommonObjectVersion = xmlCOVersion.InnerText; //sqlStatement.NodeVersion = xmlNodeObjectVersion.InnerText; XmlElement xmlPrimaryKeyField = util.Child(xmlParent, SqlPrimaryKey.SQLPRIMARYKEY); sqlStatement.PrimaryKeys.FromXml(sqlStatement.PrimaryKeys, xmlPrimaryKeyField, xnm); }
public override void FromXml(SqlElement sqlElement, XmlElement xmlParent, XmlNamespaceManager xnm) { base.FromXml(sqlElement, xmlParent, xnm); SelectListField selectListField = sqlElement as SelectListField; ParserUtil util = new ParserUtil(xnm); XmlElement xmlFieldAlias = util.Child(xmlParent, FIELDALIAS); selectListField.FieldAlias = xmlFieldAlias.InnerText; }
/// <summary> /// 用XmlElement的信息构造SqlNode类的对象(或继承自SqlNode类的对象)。 /// </summary> /// <param name="sqlElement">SqlNode类的对象(或继承自SqlNode类的对象)</param> /// <param name="xmlParent">XmlDocument中的元素</param> /// <param name="xnm">集合命名空间范围管理类的对象</param> public override void FromXml(SqlElement sqlElement, XmlElement xmlParent, XmlNamespaceManager xnm) { base.FromXml(sqlElement, xmlParent, xnm); FromItem fromItem = sqlElement as FromItem; ParserUtil util = new ParserUtil(xnm); XmlElement xmlTable = util.Child(xmlParent, SqlTable.TABLE); fromItem.Table.FromXml(fromItem.Table, xmlTable, xnm); }
/// <summary> /// 转换成Insert语句 /// </summary> /// <param name="sqlNode">SQL元素</param> /// <param name="xmlParent">XML父节点元素</param> /// <param name="xnm">集合命名空间范围管理类的对象</param> public override void FromXml(SqlElement sqlNode, XmlElement xmlParent, XmlNamespaceManager xnm) { base.FromXml(sqlNode, xmlParent, xnm); Field field = sqlNode as Field; ParserUtil util = new ParserUtil(xnm); XmlElement xmlTable = util.Child(xmlParent, SqlTable.TABLE); if (xmlTable != null) { field.Table.FromXml(field.Table, xmlTable, xnm); } XmlElement xmlFieldName = util.Child(xmlParent, FIELDNAME); XmlElement xmlIsUseFieldPrefix = util.Child(xmlParent, ISUSEFIELDPREFIX); field.FieldName = xmlFieldName.InnerText; field.IsUseFieldPrefix = bool.Parse(xmlIsUseFieldPrefix.InnerText); }
public override void FromXml(SqlElement sqlElement, XmlElement xmlParent, XmlNamespaceManager xnm) { base.FromXml(sqlElement, xmlParent, xnm); ParserUtil util = new ParserUtil(xnm); XmlElement tableNameElement = util.Child(xmlParent, TABLENAME); XmlElement tableAliasElement = util.Child(xmlParent, TABLEALIAS); XmlElement realTableNameElement = util.Child(xmlParent, REALTABLENAME); if (tableNameElement != null) { (sqlElement as SqlTable).TableName = tableNameElement.InnerText; } if (tableAliasElement != null) { (sqlElement as SqlTable).TableAlias = tableAliasElement.InnerText; } if (realTableNameElement != null) { (sqlElement as SqlTable).RealTableName = realTableNameElement.InnerText; } }
public override void FromXml(SqlElement sqlElement, XmlElement xmlParent, XmlNamespaceManager xnm) { base.FromXml(sqlElement, xmlParent, xnm); SelectSqlForSubQuery subQuery = sqlElement as SelectSqlForSubQuery; ParserUtil util = new ParserUtil(xnm); XmlElement xmlFrom = util.Child(xmlParent, From.FROM); XmlElement xmlJoinCondition = util.Child(xmlParent, JoinConditionStatement.JOINCONDITIONSTATEMENT); XmlElement xmlCondition = util.Child(xmlParent, ConditionStatement.CONDITIONSTATEMENT); subQuery.From.FromXml(subQuery.From, xmlFrom, xnm); subQuery.JoinCondition.FromXml(subQuery.JoinCondition, xmlJoinCondition, xnm); subQuery.Condition.FromXml(subQuery.Condition, xmlCondition, xnm); /* * MainFromItem和JoinSubQueryConditionItem只序列化,不反序列化。 * 其反序列化操作已包含在From和JoinCondition的集合中,直接从集合中取即可。 * */ subQuery.mainFromItem = this.From.ChildCollection[0] as FromItem; subQuery.joinSubQueryConditionItem = this.JoinCondition.ChildCollection[0] as JoinConditionItem; }
/// <summary> /// 转换成Insert语句 /// </summary> /// <param name="sqlElement">SQL元素</param> /// <param name="xmlParent">XML父节点元素</param> /// <param name="xnm">集合命名空间范围管理类的对象</param> public override void FromXml(SqlElement sqlElement, XmlElement xmlParent, XmlNamespaceManager xnm) { base.FromXml(sqlElement, xmlParent, xnm); var xnm2 = new XmlNamespaceManager(xmlParent.OwnerDocument.NameTable); InsertSqlStaMSS insertSql = sqlElement as InsertSqlStaMSS; ParserUtil util = new ParserUtil(xnm); XmlElement xmlInsertFields = util.Child(xmlParent, InsertFieldList.INSERTFIELDLIST); //XmlElement xmlInsertValues = util.Child(xmlParent, InsertValueList.INSERTVALUELIST); insertSql.InsertFields.FromXml(insertSql.InsertFields, xmlInsertFields, xnm); //insertSql.InsertValues.FromXml(insertSql.InsertValues, xmlInsertValues, xnm); }