You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Entity not persisted to the storage in the corner case #439
When entity created and SaveChanges not triggered and exception thrown on query translation
internal class Program
{
private static void Main(string[] args)
{
var currentConnection =
new SqlConnectionStringBuilder(DbHelper.ConnectionString());
var dc = new DomainConfiguration("sqlserver", currentConnection.ToString());
dc.Types.Register(typeof(TestEntity));
dc.UpgradeMode = DomainUpgradeMode.Recreate;
using var d = Domain.Build(dc);
using var s = d.OpenSession();
using var a = s.Activate();
using var t = s.OpenTransaction();
var item = new TestEntity(s, 123)
{
Name = "test"
};
// OK WHEN
// s.SaveChanges();
try
{
Expression<Func<TestEntity, bool>> expression = it => Query.All<TestEntity>()
.Where(e => e.Name == it.Name)
.Contains(it);
expression.Compile().Invoke(null);
}
catch (Exception e)
{
// System.NullReferenceException in Xtensive.Orm.Providers.CommandFactory.GetParameterValue
Console.WriteLine(e);
}
Assert.NotNull(item);
Assert.AreEqual(1, Query.All<TestEntity>().Count(it => it.Id == item.Id));
}
[HierarchyRoot]
public class TestEntity : Entity
{
public TestEntity(Session session, int id)
: base(session, id)
{
}
[Key] [Field] public int Id { get; private set; }
[Field] public string Name { get; set; }
}
}
Activity