private void RemoveFromInsert(EntityProperty property) { if (InsertFields.Contains(property)) { InsertFields.Remove(property); } }
/// <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();"); }
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))); }
/// <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); }
/// <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); }
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); } }