private void AddEntityUpdateStatement(IChild child, EntityInfo childInfo, DateTime timeStamp) { var builder = new ComplexCommandBuilder(); var idParameter = child.Id.ToParameter(); builder.AddParameter(idParameter); var whereClause = string.Format("{0}.{1} = {2}", childInfo.Name, childInfo.Identifier.Name, idParameter.Name); var statement = new UpdateStatement(childInfo.Name, whereClause); var timeStampParameter = timeStamp.ToParameter(); statement.Set(childInfo.TimeStamp.Name, timeStampParameter.Name); builder.AddParameter(timeStampParameter); foreach (var element in childInfo.Elements.Where(x => !x.IsReadOnly)) { var value = element.GetValue(child); var parameter = value.ToParameter(); statement.Set(element.Name, parameter.Name); builder.AddParameter(parameter); } foreach (var dataType in childInfo.DataTypes) { foreach (var element in dataType.Elements) { var value = dataType.GetValue(element, child); var parameter = value.ToParameter(); statement.Set(element.Name, parameter.Name); builder.AddParameter(parameter); } } builder.AddStatement(statement); Add(builder); AddSaveStatements(child, childInfo, timeStamp); child.Save(timeStamp); }
private void AddValueMoveStatement(IValue value, ValueInfo valueInfo) { var builder = new ComplexCommandBuilder(); var idParameter = value.Id.ToParameter(); builder.AddParameter(idParameter); var whereClause = string.Format("{0}.{1} = {2}", valueInfo.Name, valueInfo.Identifer.Name, idParameter.Name); var statement = new UpdateStatement(valueInfo.Name, whereClause); var seq = valueInfo.Sequence.GetValue(value); var sequenceParameter = seq.ToParameter(); statement.Set(valueInfo.Sequence.Name, sequenceParameter.Name); builder.AddParameter(sequenceParameter); builder.AddStatement(statement); Add(builder); value.Save(); }