コード例 #1
0
        private void CreateMapperDictionary(Stream mapperStream)
        {
            XmlDocument doc = new XmlDocument();

            doc.Load(mapperStream);
            //解析实体类与表的映射
            XmlNodeList nl = doc.GetElementsByTagName("class");

            foreach (XmlNode node in nl)
            {
                string className = node.Attributes["name"].Value;
                string tableName = node.Attributes["table"].Value;

                //解析属性与字段的映射
                XmlClassMap classMap = new XmlClassMap(className, tableName);
                XmlNodeList childNl  = node.ChildNodes;
                foreach (XmlNode childNode in childNl)
                {
                    if (childNode.Name == "property")
                    {
                        #region 解析属性

                        string propertyName = childNode.Attributes["name"].Value;
                        string columnName   = childNode.Attributes["column"].Value;

                        XmlPropertyMap propertyMap = new XmlPropertyMap(propertyName, columnName);
                        classMap.Properties.Add(propertyName, propertyMap);

                        #endregion
                        #region 解析自增列

                        XmlAttribute attrIdentity = childNode.Attributes["isIdentity"];
                        if (attrIdentity != null && attrIdentity.Value == "true")
                        {
                            classMap.Identity = propertyMap;
                        }

                        #endregion
                        #region 解析主键

                        XmlAttribute attrPK = childNode.Attributes["isPK"];
                        if (attrPK != null && attrPK.Value == "true")
                        {
                            classMap.Ids.Add(propertyName, propertyMap);
                        }

                        #endregion
                    }
                }
                mapperDictionary.Add(className, classMap);
            }
            mapperStream.Close();
            mapperStream.Dispose();
        }
コード例 #2
0
 /// <summary>
 /// Creates a new instance of the <see cref="XmlPropertyMapExpression" /> class.
 /// </summary>
 /// <param name="map">XmlPropertyMap to use.</param>
 public XmlPropertyMapExpression(XmlPropertyMap map)
 {
     this.map = map;
 }
コード例 #3
0
 /// <summary>
 /// Creates a new instance of the <see cref="XmlPropertyMapExpression" /> class.
 /// </summary>
 /// <param name="map">XmlPropertyMap to use.</param>
 public XmlPropertyMapExpression(XmlPropertyMap map)
 {
     this.map = map;
 }