public void SqlServerInsertCommand() { var ins = new SqlServerCmd("dbo.Table1", "Id") { { "FirstName", "Adam" }, { "LastName", "O'Neil" } }; var cmd = ins.GetInsertStatement(); Assert.IsTrue(cmd.ReplaceWhitespace().Equals( @"INSERT INTO [dbo].[Table1] ( [FirstName], [LastName] ) VALUES ( @FirstName, @LastName ); SELECT SCOPE_IDENTITY();".ReplaceWhitespace())); }
public void SqlServerInsertWithExpression() { var ins = new SqlServerCmd("dbo.Table1", "Id") { { "FirstName", "Adam" }, { "LastName", "O'Neil" }, { "CurrentDate", new SqlExpression("getdate()") } }; var cmd = ins.GetInsertStatement(); Assert.IsTrue(cmd.ReplaceWhitespace().Equals( @"INSERT INTO [dbo].[Table1] ( [FirstName], [LastName], [CurrentDate] ) VALUES ( @FirstName, @LastName, getdate() ); SELECT SCOPE_IDENTITY();".ReplaceWhitespace())); }