コード例 #1
0
 private void RemoveFromInsert(EntityProperty property)
 {
     if (InsertFields.Contains(property))
     {
         InsertFields.Remove(property);
     }
 }
コード例 #2
0
        /// <summary>
        /// 生成新增数据语句
        /// </summary>
        /// <returns></returns>
        public override string BuildInsert()
        {
            var fileds = InsertFields.Select(f => "`" + f + "`").ToList();
            var values = InsertFields.Select(f => "@" + f).ToList();

            return($"INSERT INTO {TableName} ({ string.Join(" , ", fileds)}) VALUES ({ string.Join(" , ", values)}); SELECT LAST_INSERT_ID();");
        }
コード例 #3
0
        private EntityProperty GetMemberByName(string memberName)
        {
            var property = SelectFields.FirstOrDefault(p => p.Property.Equals(memberName));

            if (property != null)
            {
                return(property);
            }

            property = InsertFields.FirstOrDefault(p => p.Property.Equals(memberName));

            return(property ?? UpdateFields.FirstOrDefault(p => p.Property.Equals(memberName)));
        }
コード例 #4
0
        /// <summary>
        /// 克隆
        /// </summary>
        /// <returns>Insert插入语句</returns>
        public override object Clone()
        {
            var sql = base.Clone() as InsertSqlStaMySQL;

            if (InsertFields != null)
            {
                sql.InsertFields = InsertFields.Clone() as InsertFieldList;
            }
            if (InsertValues != null)
            {
                sql.InsertValues = InsertValues.Clone() as InsertValueList;
            }

            return(sql);
        }
コード例 #5
0
        /// <summary>
        /// 转换成SQL
        /// </summary>
        /// <returns>SQL</returns>
        public override string ToSQL()
        {
            string insertSQL = string.Empty;

            //先从内存缓存中获取
            //insertSQL = SQLStatementManager.Instance.
            //    GetSqlStringByCache(CommonObjectID, NodeID, TableName, "ForInsert", RequestTokenID);

            if (string.IsNullOrWhiteSpace(insertSQL))
            {
                insertSQL = string.Format("INSERT INTO {0} {1}", this.TableName, InsertFields.ToSQL().Replace("\"", ""));
                // 将解析好的SQL插入缓存中
                //SQLStatementManager.Instance.
                //    SaveSqlStringToCache(CommonObjectID, NodeID, TableName, queryType.ToString(), RequestTokenID, insertSQL);
            }

            return(insertSQL);
        }
コード例 #6
0
        private void Add(EntityProperty property)
        {
            if (property.IsKey)
            {
                KeyField = property;
            }

            if (property.IsSelectable)
            {
                SelectFields.Add(property);
            }

            if (property.IsInsertable)
            {
                InsertFields.Add(property);
            }

            if (property.IsUpdatable)
            {
                UpdateFields.Add(property);
            }
        }