I'm having trouble saving an object in a SQL Server 2005 database. I am using NHibernate 2.0.0.3002 for my save level. The mapping is typically with an integer identifier, as follows
<id name="Id" unsaved-value="0">
<column name="Id"/>
<generator class="identity" />
</id>
I left the rest for brevity. The application uses the repository class with a common save method, as shown below.
public void Save(T toSave)
{
Save(new T[] { toSave });
}
public void Save(IEnumerable<T> toSave)
{
using (ISession session = SessionFactory.OpenSession())
{
foreach (T item in toSave)
{
session.SaveOrUpdate(item);
}
session.Flush();
}
}
SaveOrUpdate " ". , , , , NHibernate Id , @@IDENTITY. SQL Profiler, @@IDENTITY , , .
- ?