Exemple #1
0
        /// <summary>
        /// 获取主键名称
        /// </summary>
        /// <returns></returns>
        public string GetPrimaryKey()
        {
            ColumnRule tempColumn = this.ColumnRules.Where(t => t.IsPrimary == true).FirstOrDefault();


            return(tempColumn != null ? tempColumn.Name : "");
        }
Exemple #2
0
        /// <summary>
        /// 根据XML获取对应表实体
        /// </summary>
        /// <param name="entityElement"></param>
        /// <returns></returns>
        public void SetTableRule(XElement entityElement)
        {
            #region 属性
            this.Name = entityElement.Attribute("Name") != null?entityElement.Attribute("Name").Value : "";

            this.Remark = entityElement.Attribute("Remark") != null?entityElement.Attribute("Remark").Value : "";

            this.HasLog = (entityElement.Attribute("HasLog") != null && entityElement.Attribute("HasLog").Value == "true") ? true : false;
            #endregion

            #region 字段
            List <ColumnRule> columns = new List <ColumnRule>();

            foreach (var tempElement in entityElement.Elements("Column"))
            {
                ColumnRule tempColumn = new ColumnRule(tempElement);

                columns.Add(tempColumn);
            }

            this.ColumnRules = columns;

            ColumnRule createUser = new ColumnRule(XElement.Parse("<Column Name=\"createUserId\" Remark=\"创建用户\" />"));
            ColumnRule updateUser = new ColumnRule(XElement.Parse("<Column Name=\"updateUserId\" Remark=\"更新用户\" />"));

            this.ColumnRules.Add(createUser);
            this.ColumnRules.Add(updateUser);
            #endregion

            #region 级联
            List <CascadeRule> cascades = new List <CascadeRule>();

            foreach (var tempElement in entityElement.Elements("Cascade"))
            {
                CascadeRule tempCascade = new CascadeRule(tempElement);

                cascades.Add(tempCascade);
            }

            this.CascadeRules = cascades;
            #endregion
        }