Skip to content

Commit e866fbf

Browse files
committed
Fixes #6 - initialize proxies async
1 parent 6c6fd68 commit e866fbf

File tree

4 files changed

+28
-2
lines changed

4 files changed

+28
-2
lines changed

Src/NHibernate.Envers.Tests/NetSpecific/Integration/ForceInitialize/ForceInitializeTest.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,14 @@ public void InitializeManyToOneNull()
5656
NHibernateUtil.IsInitialized(parent.RelatedEntity).Should().Be.True();
5757
parent.RelatedEntity.Should().Be.Null();
5858
}
59+
60+
[Test]
61+
public void InitializeManyToOneNullAsync()
62+
{
63+
var parent = AuditReader().Find<Parent>(parentId, 1);
64+
NHibernateUtil.IsInitialized(parent.RelatedEntity).Should().Be.True();
65+
parent.RelatedEntity.Should().Be.Null();
66+
}
5967

6068
[Test]
6169
public void InitializeManyToOneNotNull()
@@ -67,6 +75,17 @@ public void InitializeManyToOneNotNull()
6775
parent.RelatedEntity.Id.Should().Be.EqualTo(relatedId);
6876
parent.RelatedEntity.Str.Should().Be.EqualTo("R_1_1");
6977
}
78+
79+
[Test]
80+
public void InitializeManyToOneNotNullAsync()
81+
{
82+
var parent = AuditReader().Find<Parent>(parentId, 2);
83+
NHibernateUtil.IsInitialized(parent.RelatedEntity).Should().Be.False();
84+
NHibernateUtil.InitializeAsync(parent.RelatedEntity);
85+
NHibernateUtil.IsInitialized(parent.RelatedEntity).Should().Be.True();
86+
parent.RelatedEntity.Id.Should().Be.EqualTo(relatedId);
87+
parent.RelatedEntity.Str.Should().Be.EqualTo("R_1_1");
88+
}
7089

7190
[Test]
7291
public void InitializeOneToManyEmpty()
@@ -136,6 +155,5 @@ protected override void AddToConfiguration(Cfg.Configuration configuration)
136155
{
137156
configuration.Properties[NHibernate.Cfg.Environment.GenerateStatistics] = "true";
138157
}
139-
140158
}
141159
}

Src/NHibernate.Envers/Entities/Mapper/Relation/Lazy/AbstractDelegateSessionImplementor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public Task<object> InternalLoadAsync(string entityName, object id, bool eager,
3939
return _session.InternalLoadAsync(entityName, id, eager, isNullable, cancellationToken);
4040
}
4141

42-
public Task<object> ImmediateLoadAsync(string entityName, object id, CancellationToken cancellationToken)
42+
public virtual Task<object> ImmediateLoadAsync(string entityName, object id, CancellationToken cancellationToken)
4343
{
4444
return _session.ImmediateLoadAsync(entityName, id, cancellationToken);
4545
}

Src/NHibernate.Envers/Entities/Mapper/Relation/Lazy/ToOneDelegateSessionImplementor.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
using System.Threading;
2+
using System.Threading.Tasks;
13
using NHibernate.Envers.Configuration;
24
using NHibernate.Envers.Reader;
35

@@ -27,5 +29,10 @@ public override object ImmediateLoad(string entityName, object id)
2729
{
2830
return ToOneEntityLoader.LoadImmediate(_versionsReader, _entityName, _entityId, _revision, _removed, _verCfg);
2931
}
32+
33+
public override Task<object> ImmediateLoadAsync(string entityName, object id, CancellationToken cancellationToken)
34+
{
35+
return Task.FromResult(ImmediateLoad(entityName, id));
36+
}
3037
}
3138
}

Src/ReleaseNotes.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
** Bug
1111
* #2 Make conversion of RevisionType explicit to avoid failure using Npgsql
12+
* #6 Support async proxy initialization
1213

1314

1415

0 commit comments

Comments
 (0)