Example #1
0
        /// <summary>
        /// 初始化对象配置
        /// </summary>
        /// <param name="xmlwr"></param>
        private void InitModelSetting(IO.XmlHelper xmlwr)
        {
            var modelnodes = xmlwr.GetNodeListByDelegate(delegate(XmlNode xn)
            {
                return(xn.Name.Equals(ModelSettingNodeName, StringComparison.CurrentCultureIgnoreCase) &&
                       xn.ParentNode != null && xn.ParentNode.Name.Equals(ModelSettingParentNodeName, StringComparison.CurrentCultureIgnoreCase));
            });

            if (modelnodes != null)
            {
                ModelSettings = new List <ModelSetting>();
                foreach (var xn in modelnodes)
                {
                    var model = new ModelSetting();
                    model.Contract = IO.XmlHelper.ReadAttributeValue(xn, "contract");           //读取类型

                    model.TableName  = IO.XmlHelper.ReadAttributeValue(xn, "TableName/value");  //表名
                    model.PrimaryKey = IO.XmlHelper.ReadAttributeValue(xn, "PrimaryKey/value"); //表的主健
                    //model.Fields = IO.XmlWR.ReadAttributeValue(xn, "Model/Fields/value");//字段
                    model.Mapping = IO.XmlHelper.ReadAttributeValue(xn, "Mapping/value");       //获取映射

                    foreach (XmlNode cn in xn.ChildNodes)
                    {
                        if (cn.Name.Equals(SelectNodeName, StringComparison.OrdinalIgnoreCase))//查询字段
                        {
                            model.Selects = GetCommandFromNode(cn);
                        }
                        else if (cn.Name.Equals(InsertNodeName, StringComparison.OrdinalIgnoreCase))//新增需要插入的字段
                        {
                            model.InsertCommands = GetCommandFromNode(cn);
                        }
                        else if (cn.Name.Equals(UpdateNodeName, StringComparison.OrdinalIgnoreCase))//修改需要插入的字段
                        {
                            model.UpdateCommands = GetCommandFromNode(cn);
                        }
                    }

                    ModelSettings.Add(model);
                }
            }
        }
Example #2
0
        /// <summary>
        /// 初始化对象配置
        /// </summary>
        /// <param name="xmlwr"></param>
        private void InitModelSetting(IO.XmlHelper xmlwr)
        {
            var modelnodes = xmlwr.GetNodeListByDelegate(delegate(XmlNode xn)
            {
                return xn.Name.Equals(ModelSettingNodeName, StringComparison.CurrentCultureIgnoreCase) &&
                    xn.ParentNode != null && xn.ParentNode.Name.Equals(ModelSettingParentNodeName, StringComparison.CurrentCultureIgnoreCase);
            });

            if (modelnodes != null)
            {
                ModelSettings = new List<ModelSetting>();
                foreach (var xn in modelnodes)
                {
                    var model = new ModelSetting();
                    model.Contract = IO.XmlHelper.ReadAttributeValue(xn, "contract");//读取类型

                    model.TableName = IO.XmlHelper.ReadAttributeValue(xn, "TableName/value");//表名
                    model.PrimaryKey = IO.XmlHelper.ReadAttributeValue(xn, "PrimaryKey/value");//表的主健
                    //model.Fields = IO.XmlWR.ReadAttributeValue(xn, "Model/Fields/value");//字段
                    model.Mapping = IO.XmlHelper.ReadAttributeValue(xn, "Mapping/value");//获取映射

                    foreach (XmlNode cn in xn.ChildNodes)
                    {     
                        if (cn.Name.Equals(SelectNodeName, StringComparison.OrdinalIgnoreCase))//查询字段
                        {
                            model.Selects = GetCommandFromNode(cn);                           
                        }
                        else if (cn.Name.Equals(InsertNodeName, StringComparison.OrdinalIgnoreCase))//新增需要插入的字段
                        {
                            model.InsertCommands = GetCommandFromNode(cn);                    
                        }
                        else if (cn.Name.Equals(UpdateNodeName, StringComparison.OrdinalIgnoreCase))//修改需要插入的字段
                        {
                            model.UpdateCommands = GetCommandFromNode(cn);                            
                        }                        
                    }
             
                    ModelSettings.Add(model);
                }
            }
        }