-
Notifications
You must be signed in to change notification settings - Fork 936
Closed
Closed
Copy link
Description
I updated the NHibernate from 5.2.7 to 5.3.0 and noticed that there is a difference between the returning object from the merge function. In version 5.3.x the merge function doesn't return the entity id if the entity is not in the database but in version 5.2.7 the merge function returns the entity id. I don't know this is a bug or not
Here is the code
using NHibernate.Cfg;
using NHibernate.Dialect;
using NHibernate.Driver;
using NHibernate.Mapping.ByCode;
using NHibernate.Mapping.ByCode.Conformist;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace TestNHibernate
{
class Program
{
static void Main(string[] args)
{
var cfg = new Configuration();
cfg.DataBaseIntegration(x =>
{
x.ConnectionString = "Data Source=.;integrated security=true;Initial Catalog=TestDB;MultipleActiveResultSets=True";
x.Driver<SqlClientDriver>();
x.Dialect<MsSql2008Dialect>();
});
cfg.AddAssembly(Assembly.GetExecutingAssembly());
var sefact = cfg.BuildSessionFactory();
using (var session = sefact.OpenSession())
{
var person = new Person
{
Name= "Jamie"
};
using (var tx = session.BeginTransaction())
{
var merged = session.Merge(person);
session.SaveOrUpdate(merged);
tx.Commit();
}
Console.ReadLine();
}
}
}
public class Person
{
public virtual int ID { get; set; }
public virtual string Name { get; set; }
public virtual string Tel { get; set; }
}
}