Skip to content
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
2 changes: 1 addition & 1 deletion Tools/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
<package id="NUnit.Extension.NUnitV2ResultWriter" version="3.6.0" targetFramework="net461" />
<package id="NUnit.Extension.TeamCityEventListener" version="1.0.2" targetFramework="net461" />
<package id="NUnit.Extension.VSProjectLoader" version="3.6.0" targetFramework="net461" />
<package id="CSharpAsyncGenerator.CommandLine" version="0.4.3" targetFramework="net461" />
<package id="CSharpAsyncGenerator.CommandLine" version="0.4.4" targetFramework="net461" />
</packages>
24 changes: 23 additions & 1 deletion doc/reference/modules/query_linq.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,28 @@ using NHibernate.Linq;]]></programlisting>
.Where(c => c.Name == "Max")
.ToList();]]></programlisting>

<para>
Starting with NHibernate 5.0, queries can also be created from an entity collection, with the standard
Linq extension <literal>AsQueryable</literal> available from <literal>System.Linq</literal> namespace.
</para>
<programlisting><![CDATA[IList<Cat> whiteKittens =
cat.Kittens.AsQueryable()
.Where(k => k.Color == "white")
.ToList();]]></programlisting>
<para>
This will be executed as a query on that <literal>cat</literal>'s kittens without loading the
entire collection.
</para>
<para>
If the collection is a map, call <literal>AsQueryable</literal> on its <literal>Values</literal>
property.
</para>
<programlisting><![CDATA[IList<Cat> whiteKittens =
cat.Kittens.Values.AsQueryable()
.Where(k => k.Color == "white")
.ToList();]]></programlisting>
<para>&nbsp;</para>

<para>
A client timeout for the query can be defined.
</para>
Expand Down Expand Up @@ -789,4 +811,4 @@ cfg.LinqToHqlGeneratorsRegistry<ExtendedLinqToHqlGeneratorsRegistry>();
</para>
</sect2>
</sect1>
</chapter>
</chapter>
5 changes: 4 additions & 1 deletion src/NHibernate.Test/Async/NHSpecificTest/Logs/LogsFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public class TextLogSpy : IDisposable
private readonly TextWriterAppender appender;
private readonly Logger loggerImpl;
private readonly StringBuilder stringBuilder;
private readonly Level previousLevel;

public TextLogSpy(string loggerName, string pattern)
{
Expand All @@ -84,6 +85,7 @@ public TextLogSpy(string loggerName, string pattern)
};
loggerImpl = (Logger)LogManager.GetLogger(typeof(LogsFixtureAsync).Assembly, loggerName).Logger;
loggerImpl.AddAppender(appender);
previousLevel = loggerImpl.Level;
loggerImpl.Level = Level.All;
}

Expand All @@ -98,9 +100,10 @@ public string[] Events
public void Dispose()
{
loggerImpl.RemoveAppender(appender);
loggerImpl.Level = previousLevel;
}
}
}


}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ public async Task LoadCompositeElementsWithWithSimpleHbmAliasInjectionAsync()
Country country = await (LoadCountryWithNativeSQLAsync(CreateCountry(stats), "LoadAreaStatisticsWithSimpleHbmAliasInjection"));

Assert.That(country, Is.Not.Null);
Assert.That((ICollection) country.Statistics.Keys, Is.EquivalentTo((ICollection) stats.Keys), "Keys");
Assert.That((ICollection) country.Statistics.Values, Is.EquivalentTo((ICollection) stats.Values), "Elements");
Assert.That(country.Statistics.Keys, Is.EquivalentTo(stats.Keys), "Keys");
Assert.That(country.Statistics.Values, Is.EquivalentTo(stats.Values), "Elements");
await (CleanupWithPersonsAsync());
}

Expand All @@ -63,8 +63,8 @@ public async Task LoadCompositeElementsWithWithComplexHbmAliasInjectionAsync()
Country country = await (LoadCountryWithNativeSQLAsync(CreateCountry(stats), "LoadAreaStatisticsWithComplexHbmAliasInjection"));

Assert.That(country, Is.Not.Null);
Assert.That((ICollection) country.Statistics.Keys, Is.EquivalentTo((ICollection) stats.Keys), "Keys");
Assert.That((ICollection) country.Statistics.Values, Is.EquivalentTo((ICollection) stats.Values), "Elements");
Assert.That(country.Statistics.Keys, Is.EquivalentTo(stats.Keys), "Keys");
Assert.That(country.Statistics.Values, Is.EquivalentTo(stats.Values), "Elements");
await (CleanupWithPersonsAsync());
}

Expand All @@ -75,8 +75,8 @@ public async Task LoadCompositeElementsWithWithCustomAliasesAsync()
Country country = await (LoadCountryWithNativeSQLAsync(CreateCountry(stats), "LoadAreaStatisticsWithCustomAliases"));

Assert.That(country, Is.Not.Null);
Assert.That((ICollection) country.Statistics.Keys, Is.EquivalentTo((ICollection) stats.Keys), "Keys");
Assert.That((ICollection) country.Statistics.Values, Is.EquivalentTo((ICollection) stats.Values), "Elements");
Assert.That(country.Statistics.Keys, Is.EquivalentTo(stats.Keys), "Keys");
Assert.That(country.Statistics.Values, Is.EquivalentTo(stats.Values), "Elements");

await (CleanupWithPersonsAsync());
}
Expand Down Expand Up @@ -201,8 +201,8 @@ public async Task LoadCompositeElementCollectionWithCustomLoaderAsync()
{
var a = await (session.GetAsync<Area>(country.Code));
Assert.That(a, Is.Not.Null, "area");
Assert.That((ICollection) a.Statistics.Keys, Is.EquivalentTo((ICollection) stats.Keys), "area.Keys");
Assert.That((ICollection) a.Statistics.Values, Is.EquivalentTo((ICollection) stats.Values), "area.Elements");
Assert.That(a.Statistics.Keys, Is.EquivalentTo(stats.Keys), "area.Keys");
Assert.That(a.Statistics.Values, Is.EquivalentTo(stats.Values), "area.Elements");
}
await (CleanupWithPersonsAsync());
}
Expand Down Expand Up @@ -428,4 +428,4 @@ private static IDictionary<int, AreaStatistics> CreateStatistics()

#endregion
}
}
}
Loading