Uploaded image for project: 'NHibernate [Moved to GitHub]'
  1. NH-4072

Add parameter of FormattableString as an overload to CreateSQLQuery

    Details

    • Type: New Feature
    • Status: Resolved
    • Priority: Trivial
    • Resolution: Won't Fix
    • Affects versions: 5.0.0
    • Fix versions: None
    • Components: Core
    • Labels:
    • Sprint:

      Description

      .NET 4.6.1 has access to a new type, FormattableString, that can get information from an interpolated string

      $"hello {name}"
      

      So the idea is that CreateSQLQuery would add an overload taking FormattableString so that this:

      string filter = "Pus%";
      Query query = sess.CreateSQLQuery("SELECT * FROM CATS WHERE NAME like ?")
          .AddEntity(typeof(Cat));
      IList pusList = query.SetString(0, filter).List();
      

      could become:

      string filter = "Pus%";
      IList pusList = sess.CreateSQLQuery($"SELECT * FROM CATS WHERE NAME like {filter}")
          .AddEntity(typeof(Cat))
          .List();
      

      As a benefit, it would also catch any sql injection when interpolation is used.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              shiften Nathan Brown
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Who's Looking?