Skip to content

Commit

Permalink
Resharper: simplify dictionary lookups
Browse files Browse the repository at this point in the history
  • Loading branch information
bkoelman committed Nov 17, 2023
1 parent 43ed741 commit 1e0d9c9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ private TableAccessorNode CreatePrimaryTableWithIdentityCondition(TableSourceNod
private TableAccessorNode? FindRelatedTable(TableAccessorNode leftTableAccessor, RelationshipAttribute relationship)
{
Dictionary<RelationshipAttribute, TableAccessorNode> rightTableAccessors = _queryState.RelatedTables[leftTableAccessor];
return rightTableAccessors.TryGetValue(relationship, out TableAccessorNode? rightTableAccessor) ? rightTableAccessor : null;
return rightTableAccessors.GetValueOrDefault(relationship);
}

private SelectNode ToSelect(bool isSubQuery, bool createAlias)
Expand Down
4 changes: 2 additions & 2 deletions src/JsonApiDotNetCore/Configuration/ResourceGraph.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public ResourceType GetResourceType(string publicName)
{
ArgumentGuard.NotNull(publicName);

return _resourceTypesByPublicName.TryGetValue(publicName, out ResourceType? resourceType) ? resourceType : null;
return _resourceTypesByPublicName.GetValueOrDefault(publicName);
}

/// <inheritdoc />
Expand All @@ -75,7 +75,7 @@ public ResourceType GetResourceType(Type resourceClrType)
ArgumentGuard.NotNull(resourceClrType);

Type typeToFind = IsLazyLoadingProxyForResourceType(resourceClrType) ? resourceClrType.BaseType! : resourceClrType;
return _resourceTypesByClrType.TryGetValue(typeToFind, out ResourceType? resourceType) ? resourceType : null;
return _resourceTypesByClrType.GetValueOrDefault(typeToFind);
}

private bool IsLazyLoadingProxyForResourceType(Type resourceClrType)
Expand Down

0 comments on commit 1e0d9c9

Please sign in to comment.