public FreeTextParameterChangeResult CheckForChanges(string sql) { try { string oldName = Parameter.ParameterName; ConstantParameter newPrototype; newPrototype = ConstantParameter.Parse(sql, _querySyntaxHelper); if (string.Equals(newPrototype.Comment, Parameter.Comment)//can be null you see && string.Equals(newPrototype.Value, Parameter.Value) && newPrototype.ParameterSQL.Equals(Parameter.ParameterSQL)) { return(FreeTextParameterChangeResult.NoChangeMade); } Parameter.Comment = newPrototype.Comment; Parameter.Value = newPrototype.Value; Parameter.ParameterSQL = newPrototype.ParameterSQL; Parameter.SaveToDatabase(); _refactorer.HandleRename(Parameter, oldName, Parameter.ParameterName); return(FreeTextParameterChangeResult.ChangeAccepted); } catch (Exception) { return(FreeTextParameterChangeResult.ChangeRejected); } }
public ParameterEditorScintillaSection(ParameterRefactorer refactorer, int lineStart, int lineEnd, ISqlParameter parameter, bool editable, string originalText) { _refactorer = refactorer; LineStart = lineStart; LineEnd = lineEnd; Parameter = parameter; Editable = editable; _querySyntaxHelper = parameter.GetQuerySyntaxHelper(); var prototype = ConstantParameter.Parse(originalText, _querySyntaxHelper); if (prototype.Value != parameter.Value) { throw new ArgumentException("Parameter " + parameter + " was inconsistent with the SQL passed to us based on QueryBuilder.DeconstructStringIntoParameter, they had different Values"); } if (prototype.ParameterSQL != parameter.ParameterSQL) { throw new ArgumentException("Parameter " + parameter + " was inconsistent with the SQL passed to us based on QueryBuilder.DeconstructStringIntoParameter, they had different ParameterSQL"); } if (prototype.Comment != parameter.Comment) { throw new ArgumentException("Parameter " + parameter + " was inconsistent with the SQL passed to us based on QueryBuilder.DeconstructStringIntoParameter, they had different Comment"); } }
public void ParameterDeclarationAndDeconstruction() { var param = new ConstantParameter("DECLARE @Fish as int;", "3", "I've got a lovely bunch of coconuts", new MicrosoftQuerySyntaxHelper()); var sql = QueryBuilder.GetParameterDeclarationSQL(param); Assert.AreEqual(@"/*I've got a lovely bunch of coconuts*/ DECLARE @Fish as int; SET @Fish=3; ", sql); var after = ConstantParameter.Parse(sql, new MicrosoftQuerySyntaxHelper()); Assert.AreEqual(param.ParameterSQL, after.ParameterSQL); Assert.AreEqual(param.Value, after.Value); Assert.AreEqual(param.Comment, after.Comment); }