Skip to content

Obsolete JoinedEnumerable #3543

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions src/NHibernate.Test/Async/Legacy/FooBarTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
Expand Down Expand Up @@ -1222,10 +1223,7 @@ public async Task BatchLoadAsync()
await (s.DeleteAsync(baz2));
await (s.DeleteAsync(baz3));

IEnumerable en = new JoinedEnumerable(
new IEnumerable[] {baz.FooSet, baz2.FooSet});

foreach (object obj in en)
foreach (var obj in baz.FooSet.Concat(baz2.FooSet))
{
await (s.DeleteAsync(obj));
}
Expand Down Expand Up @@ -5273,16 +5271,13 @@ public async Task TransientOrphanDeleteAsync()
Baz baz = new Baz();
var bars = new HashSet<BarProxy> { new Bar(), new Bar(), new Bar() };
baz.CascadingBars = bars;
IList<Foo> foos = new List<Foo>();
foos.Add(new Foo());
foos.Add(new Foo());
var foos = new List<Foo> { new Foo(), new Foo() };
baz.FooBag = foos;
await (s.SaveAsync(baz));

IEnumerator enumer = new JoinedEnumerable(new IEnumerable[] {foos, bars}).GetEnumerator();
while (enumer.MoveNext())
foreach (var foo in foos.Concat(bars.Cast<FooProxy>()))
{
FooComponent cmp = ((Foo) enumer.Current).Component;
var cmp = foo.Component;
await (s.DeleteAsync(cmp.Glarch));
cmp.Glarch = null;
}
Expand Down
15 changes: 5 additions & 10 deletions src/NHibernate.Test/Legacy/FooBarTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
Expand Down Expand Up @@ -1210,10 +1211,7 @@ public void BatchLoad()
s.Delete(baz2);
s.Delete(baz3);

IEnumerable en = new JoinedEnumerable(
new IEnumerable[] {baz.FooSet, baz2.FooSet});

foreach (object obj in en)
foreach (var obj in baz.FooSet.Concat(baz2.FooSet))
{
s.Delete(obj);
}
Expand Down Expand Up @@ -5261,16 +5259,13 @@ public void TransientOrphanDelete()
Baz baz = new Baz();
var bars = new HashSet<BarProxy> { new Bar(), new Bar(), new Bar() };
baz.CascadingBars = bars;
IList<Foo> foos = new List<Foo>();
foos.Add(new Foo());
foos.Add(new Foo());
var foos = new List<Foo> { new Foo(), new Foo() };
baz.FooBag = foos;
s.Save(baz);

IEnumerator enumer = new JoinedEnumerable(new IEnumerable[] {foos, bars}).GetEnumerator();
while (enumer.MoveNext())
foreach (var foo in foos.Concat(bars.Cast<FooProxy>()))
{
FooComponent cmp = ((Foo) enumer.Current).Component;
var cmp = foo.Component;
s.Delete(cmp.Glarch);
cmp.Glarch = null;
}
Expand Down
2 changes: 2 additions & 0 deletions src/NHibernate.Test/UtilityTest/JoinedEnumerableFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ namespace NHibernate.Test.UtilityTest
/// <summary>
/// Test cases for the <see cref="JoinedEnumerable"/> class.
/// </summary>
// Since v5.6
[Obsolete]
[TestFixture]
public class JoinedEnumerableFixture
{
Expand Down
3 changes: 2 additions & 1 deletion src/NHibernate/Async/Engine/Query/HQLQueryPlan.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ public async Task<IEnumerable> PerformIterateAsync(QueryParameters queryParamete
var result = await (Translators[i].GetEnumerableAsync(queryParameters, session, cancellationToken)).ConfigureAwait(false);
results[i] = result;
}
return new JoinedEnumerable(results);

return Enumerate(results);
}

public async Task<IEnumerable<T>> PerformIterateAsync<T>(QueryParameters queryParameters, IEventSource session, CancellationToken cancellationToken)
Expand Down
14 changes: 13 additions & 1 deletion src/NHibernate/Engine/Query/HQLQueryPlan.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,19 @@ public IEnumerable PerformIterate(QueryParameters queryParameters, IEventSource
var result = Translators[i].GetEnumerable(queryParameters, session);
results[i] = result;
}
return new JoinedEnumerable(results);

return Enumerate(results);
}

private static IEnumerable Enumerate(IEnumerable[] enumerables)
{
foreach (var enumerable in enumerables)
{
foreach (var o in enumerable)
{
yield return o;
}
}
}

public IEnumerable<T> PerformIterate<T>(QueryParameters queryParameters, IEventSource session)
Expand Down
2 changes: 1 addition & 1 deletion src/NHibernate/IQueryOver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ public interface IQueryOver<TRoot,TSubType> : IQueryOver<TRoot>
/// </summary>
/// <param name="path">A lambda expression path (e.g., ChildList[0].Granchildren[0].Pets).</param>
/// <returns></returns>
// Since 5.2
// Since v5.2
[Obsolete("Use Fetch(SelectMode mode, Expression<Func<TSubType, object>> path) instead")]
IQueryOverFetchBuilder<TRoot,TSubType> Fetch(Expression<Func<TRoot, object>> path);

Expand Down
2 changes: 2 additions & 0 deletions src/NHibernate/Util/JoinedEnumerable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ namespace NHibernate.Util
/// <summary>
/// Concatenates multiple objects implementing <see cref="IEnumerable"/> into one.
/// </summary>
// Since v5.6
[Obsolete("This class has no more usages in NHibernate and will be removed in a future version.")]
public class JoinedEnumerable : IEnumerable
{
private static readonly INHibernateLogger log = NHibernateLogger.For(typeof(JoinedEnumerable));
Expand Down
Loading