mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-14 02:37:08 -07: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:
parent
f5a68782ce
commit
28b47b415f
4 changed files with 56 additions and 34 deletions
|
@ -13,8 +13,10 @@ namespace NzbDrone.Core.Datastore
|
|||
where TChild : ModelBase
|
||||
{
|
||||
return relationshipBuilder.For(portalExpression.GetMemberName())
|
||||
.LazyLoad((db, parent) => db.Query<TChild>()
|
||||
.SingleOrDefault(c => c.Id == childIdSelector(parent)));
|
||||
.LazyLoad(
|
||||
query: (db, parent) => db.Query<TChild>().SingleOrDefault(c => c.Id == childIdSelector(parent)),
|
||||
condition: parent => childIdSelector(parent) > 0
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue