SqlStringBuilder builder = new SqlStringBuilder(); builder.AddClause("SELECT * FROM Customers WHERE Country = @country", "country", "UK"); string sqlQuery = builder.ToSqlString();
SqlStringBuilder builder = new SqlStringBuilder(); builder.AddClause("INSERT INTO Customers (Name, Country) VALUES (@name, @country)"); builder.AddParameter("name", "John Doe"); builder.AddParameter("country", "USA"); string sqlQuery = builder.ToSqlString();This example creates an instance of the SqlStringBuilder class and adds a SQL clause to insert a new customer record. The AddParameter method is then called twice to add two parameter values. Finally, the ToSqlString method is called to get the complete SQL statement. The NHibernate.SqlCommand namespace is included in the NHibernate package library, which is available on NuGet.