It's available in v2 and thus in this beta code
.
You've to set the SQLServer DQE in 2005 mode, by using the DynamicQueryEngine.CompatibilityLevel property, or by using the config file setting.
Typically you'll use:
DbUtils.SetSqlServerCompatibilityLevel( SqlServerCompatibilityLevel.SqlServer2005 );
somewhere at the start of your application. You can also use the config file and do:
<add key="SqlServerDQECompatibilityLevel" value="2"/>
in the appSettings section.
Then, the table has to have a DEFAULT constraint for the PK, and that default constraint has to be NEWSEQUENTIALID(); or better: (newsequentialid()) when you specify it in that horrible tool called SQL Server management studio.
The PK field obviously has to be a uniqueidentifier column.
like:
CREATE TABLE [dbo].[NewSequentialIDTest](
[ID] [uniqueidentifier] NOT NULL CONSTRAINT [DF_NewSequentialIDTest_ID] DEFAULT (newsequentialid()),
[Description] varchar COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
CONSTRAINT [PK_NewSequentialIDTest] PRIMARY KEY CLUSTERED
(
[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
then you can do in code:
/// <summary>
/// Inserts a new entity in a table which has a PK with as default value newsequentialid(). This will generate a GUID inside the db and return it to the
/// entity.
/// </summary>
[Test]
public void NewSequentialIdInsertReadBackTest()
{
// switch to 2005 mode
DbUtils.SetSqlServerCompatibilityLevel( SqlServerCompatibilityLevel.SqlServer2005 );
NewSequentialIdtestEntity newIdEntity = new NewSequentialIdtestEntity();
newIdEntity.Description = "UnitTestInsert";
Assert.IsTrue( newIdEntity.Save());
Guid id = newIdEntity.Id;
Console.WriteLine( "Id : {0}", newIdEntity.Id.ToString() );
}