public override string ToString() { if (myobject.TypeObjectId == TypeObject.None) { // pas de bras pas de chocolat return(string.Empty); } StringBuilder sql = new StringBuilder(); sql.AppendLine(); sql.AppendLine("-------------------------------------------------------------------------------"); sql.AppendLine($"--- DBComparer {Environment.UserName} le {DateTime.Now:dd/MM/yyyy} à {DateTime.Now:HH:mm} {myobject.GetTypeObject().TypeObjectTilte} {myobject}"); sql.AppendLine("-------------------------------------------------------------------------------"); string sepi = string.Empty; if (myobject.ClientCodeId > 0) { sql.AppendLine($"IF (EXISTS (SELECT 1 FROM dbo.CodeClientId({myobject.ClientCodeId})))"); sql.AppendLine("BEGIN"); sepi = " "; } if (myobject.ObjectDeleted || myAction.SqlActionId == SqlAction.Delete || myAction.SqlActionId == SqlAction.Alter) { sql.AppendLine(sepi + SQLIfExists()); sql.AppendLine(sepi + "BEGIN"); sql.AppendLine(sepi + " " + SQLDrop()); sql.AppendLine(sepi + "END"); } if (myAction.SqlActionId != SqlAction.Delete) { sql.AppendLine(); sql.AppendLine(sepi + "DECLARE @sql VARCHAR(MAX);"); sql.AppendLine(sepi + $"SELECT @sql = {SqlFormat.String(myobject.ObjectSql)}"); sql.AppendLine(sepi + "IF (ISNULL(@sql, '') <> '')"); sql.AppendLine(sepi + "BEGIN"); sql.AppendLine(sepi + " EXEC(@sql);"); sql.AppendLine(sepi + "END"); } if (myobject.ClientCodeId > 0) { sql.AppendLine("END"); } sql.AppendLine("-------------------------------------------------------------------------------"); return(sql.ToString()); }