Esempio n. 1
0
        private string SimpleCode()
        {
            var fields = Entity.DbFields.Where(p => p.ExtendConfigListBool["db_simple"]).ToArray();
            var code   = new StringBuilder();

            code.Append($@"
        #region 简单读取

        /// <summary>
        /// SQL语句
        /// </summary>
        public override string SimpleFields
        {{
            get
            {{
                return @""{SqlMomentCoder.LoadSql(fields)}"";
            }}
        }}


        /// <summary>
        /// 载入数据
        /// </summary>
        /// <param name=""reader"">数据读取器</param>
        /// <param name=""entity"">读取数据的实体</param>
        public override void SimpleLoad(MySqlDataReader reader,{this.Entity.EntityName} entity)
        {{
            using (new EditScope(entity.__EntityStatus, EditArrestMode.All, false))
            {{");

            var idx = 0;

            foreach (var field in fields)
            {
                SqlMomentCoder.FieldReadCode(field, code, idx++);
            }
            code.Append(@"
            }
        }
        #endregion");
            return(code.ToString());
        }
Esempio n. 2
0
        private string SqlCode()
        {
            return($@"
        #region 基本SQL语句

        /// <summary>
        /// 表的唯一标识
        /// </summary>
        public override int TableId
        {{
            get {{ return {this.Project.DataBaseObjectName}.Table_{this.Entity.Name}; }}
        }}

        /// <summary>
        /// 读取表名
        /// </summary>
        protected sealed override string ReadTableName
        {{
            get
            {{
                return @""{this.Entity.ReadTableName}"";
            }}
        }}

        /// <summary>
        /// 写入表名
        /// </summary>
        protected sealed override string WriteTableName
        {{
            get
            {{
                return @""{this.Entity.SaveTable}"";
            }}
        }}

        /// <summary>
        /// 主键
        /// </summary>
        protected sealed override string PrimaryKey
        {{
            get
            {{
                return @""{this.Entity.PrimaryColumn.Name}"";
            }}
        }}

        /// <summary>
        /// 全表读取的SQL语句
        /// </summary>
        protected sealed override string FullLoadFields
        {{
            get
            {{
                return @""{SqlMomentCoder.LoadSql(PublishDbFields)}"";
            }}
        }}

        

        /// <summary>
        /// 插入的SQL语句
        /// </summary>
        protected sealed override string InsertSqlCode
        {{
            get
            {{
                return @""{this.InsertSql()}"";
            }}
        }}

        /// <summary>
        /// 全部更新的SQL语句
        /// </summary>
        protected sealed override string UpdateSqlCode
        {{
            get
            {{
                return @""{this.UpdateSql()}"";
            }}
        }}

        /// <summary>
        /// 取得仅更新的SQL语句
        /// </summary>
        internal string GetModifiedSqlCode({this.Entity.EntityName} data)
        {{
            if (data.__EntityStatusNull || !data.__EntityStatus.IsModified)
                return "";"";
            StringBuilder sql = new StringBuilder();{this.UpdateSqlByModify()}
            return sql.ToString();
        }}

        #endregion
");
        }