Skip to content

Commit 1cff6eb

Browse files
author
Bart Koelman
authored
Corrected documentation on sparse fieldsets (#859)
1 parent 7da2019 commit 1cff6eb

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

docs/usage/resources/resource-definitions.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ Note: to exclude attributes unconditionally, use `[Attr(Capabilities = ~AttrCapa
2727
public class UserDefinition : JsonApiResourceDefinition<User>
2828
{
2929
public UserDefinition(IResourceGraph resourceGraph) : base(resourceGraph)
30-
{ }
30+
{
31+
}
3132

3233
public override SparseFieldSetExpression OnApplySparseFieldSet(SparseFieldSetExpression existingSparseFieldSet)
3334
{
@@ -36,10 +37,7 @@ public class UserDefinition : JsonApiResourceDefinition<User>
3637
return existingSparseFieldSet;
3738
}
3839

39-
var resourceContext = ResourceGraph.GetResourceContext<User>();
40-
var passwordAttribute = resourceContext.Attributes.Single(a => a.Property.Name == nameof(User.Password));
41-
42-
return existingSparseFieldSet.Excluding(passwordAttribute);
40+
return existingSparseFieldSet.Excluding<User>(x => x.Password, ResourceGraph);
4341
}
4442
}
4543
```

0 commit comments

Comments
 (0)