Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Dialect
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14491/NHibernate/Dialect
Modified Files:
Dialect.cs MsSql2000Dialect.cs
Log Message:
Added support for sending one command to the db to handle the Insert and
retrieval of the Id.
Index: Dialect.cs
===================================================================
RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Dialect/Dialect.cs,v
retrieving revision 1.28
retrieving revision 1.29
diff -C2 -d -r1.28 -r1.29
*** Dialect.cs 16 Apr 2004 14:12:09 -0000 1.28
--- Dialect.cs 28 Apr 2004 03:46:11 -0000 1.29
***************
*** 196,199 ****
--- 196,220 ----
/// <summary>
+ /// Does this Dialect allow adding a Sql String at the end of the
+ /// INSERT statement to retrieve the new Identity value.
+ /// </summary>
+ /// <value>defaults to false</value>
+ /// <remarks>
+ /// <para>
+ /// If the Dialect supports this then only one Command will need to be executed
+ /// against the Database to do the Insert and get the Id.
+ /// </para>
+ /// <para>
+ /// If this is overridden and returns <c>true</c> then the Dialect
+ /// is expected to override the method <see cref="AddIdentitySelectToInsert(SqlString)"/>
+ /// </para>
+ /// </remarks>
+ public virtual bool SupportsIdentitySelectInInsert
+ {
+ get { return false; }
+ }
+
+
+ /// <summary>
/// Does this dialect support identity column key generation?
/// </summary>
***************
*** 211,214 ****
--- 232,240 ----
}
+ public virtual SqlString AddIdentitySelectToInsert(SqlString insertSql)
+ {
+ throw new NotSupportedException("This Dialect does not implement AddIdentitySelectToInsert");
+ }
+
/// <summary>
/// The syntax that returns the identity value of the last insert, if native
Index: MsSql2000Dialect.cs
===================================================================
RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Dialect/MsSql2000Dialect.cs,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** MsSql2000Dialect.cs 16 Apr 2004 14:12:10 -0000 1.11
--- MsSql2000Dialect.cs 28 Apr 2004 03:46:11 -0000 1.12
***************
*** 2,5 ****
--- 2,6 ----
using System.Data;
+ using NHibernate.SqlCommand;
using NHibernate.SqlTypes;
***************
*** 38,41 ****
--- 39,62 ----
}
+ /// <summary>
+ /// MsSql allows the use of SELECT SCOPE_IDENTITY to be in the same
+ /// Command as the INSERT
+ /// </summary>
+ /// <value>true</value>
+ public override bool SupportsIdentitySelectInInsert
+ {
+ get { return true; }
+ }
+
+ /// <summary>
+ /// Add the Identity Select string to the Insert Sql.
+ /// </summary>
+ /// <param name="insertSql">The SqlString that contains the INSERT sql.</param>
+ /// <returns>A new SqlString with <c>; SELECT SCOPE_IDENTITY()</c> at the end.</returns>
+ public override SqlString AddIdentitySelectToInsert(SqlString insertSql)
+ {
+ return insertSql.Append( new SqlString("; SELECT SCOPE_IDENTITY()") );
+ }
+
public override bool SupportsIdentityColumns
{
|