Skip to content

Commit ec2ae6d

Browse files
committed
Add C# example for per-entity property whitelist
Included a C# example showing how to register a property whitelist for the Article entity using IPropertyWhitelistProvider<T>. Also added a note on centralizing whitelists for multiple entities.
1 parent 7ede07f commit ec2ae6d

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Esempio: Registrare una whitelist per un'entità
2+
3+
```csharp
4+
// esempio per Article: consentire solo "Title" e "PublishedAt" come proprietà ordinabili
5+
public class ArticleWhitelist : IPropertyWhitelistProvider<Article>
6+
{
7+
public IEnumerable<string> GetAllowedProperties() => new[] { "Title", "PublishedAt" };
8+
}
9+
10+
// in Program.cs / Startup.cs
11+
builder.Services.AddSingleton<IPropertyWhitelistProvider<Article>, ArticleWhitelist>();
12+
13+
14+
NOTA: Se vuoi una whitelist centralizzata per più entità, implementa IPropertyWhitelistProvider<T> per ogni T che ti interessa e registrala in DI.

0 commit comments

Comments
 (0)