mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2025-09-17 17:14:18 +02:00
added condition to lazy loading of relationship objects
no db calls will be made if foreign key is 0.
This commit is contained in:
@@ -62,12 +62,13 @@ namespace Marr.Data.Mapping
|
||||
/// </summary>
|
||||
/// <typeparam name="TChild"></typeparam>
|
||||
/// <param name="query"></param>
|
||||
/// <param name="condition">condition in which a child could exist. eg. avoid call to db if foreign key is 0 or null</param>
|
||||
/// <returns></returns>
|
||||
public RelationshipBuilder<TEntity> LazyLoad<TChild>(Func<IDataMapper, TEntity, TChild> query)
|
||||
public RelationshipBuilder<TEntity> LazyLoad<TChild>(Func<IDataMapper, TEntity, TChild> query, Func<TEntity, bool> condition = null)
|
||||
{
|
||||
AssertCurrentPropertyIsSet();
|
||||
|
||||
Relationships[_currentPropertyName].LazyLoaded = new LazyLoaded<TEntity, TChild>(query);
|
||||
Relationships[_currentPropertyName].LazyLoaded = new LazyLoaded<TEntity, TChild>(query, condition);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user