Esempio n. 1
0
        public virtual Dictionary <String, Object> Bind(Dapper.SqlBuilder builder)
        {
            var parameters = new Dictionary <String, Object>();

            // Are we creating an "IS NULL" query?
            if (this.IsNullComparison())
            {
                this.Comparison = Comparison.Null;
            }
            // We are doing a parameterized query
            // So construct the parameter
            else
            {
                try
                {
                    var convertedValue = Convert.ChangeType(this.Value, this.DataType);
                    parameters.Add(this.DatabaseColumnName, convertedValue);
                }
                catch (FormatException ex)
                {
                    var value = (this.Value == null ? "NULL" : this.Value.ToString());
                    var msg   = $"{this.DatabaseColumnName} failed to convert '{value}' into an {this.DataType.ToString()} - {ex.Message}";
                    throw new FormatException(msg);
                }
            }

            this.SetWhereClause(builder);

            return(parameters);
        }
Esempio n. 2
0
        // Logic scope only, no impact on the database
        public override Dictionary <String, Object> Bind(Dapper.SqlBuilder builder)
        {
            var parameters = new Dictionary <String, Object>();

            parameters.Add("", null);

            return(parameters);
        }
Esempio n. 3
0
 /// <summary>
 /// Set's the "WHERE clause" for this binding
 /// </summary>
 /// <param name="builder">The SQL Builder instance to use</param>
 private void SetWhereClause(Dapper.SqlBuilder builder)
 {
     if (this.Comparison == Comparison.Equals)
     {
         builder.Where($"{this.DatabaseColumnName} = @{this.DatabaseColumnName}");
     }
     else if (this.Comparison == Comparison.Null)
     {
         builder.Where($"{this.DatabaseColumnName} IS NULL");
     }
     else
     {
         throw new NotImplementedException("This constraint comparison type is not implemented yet");
     }
 }