Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Intercept resolution of entity type #34765

Open
kjkrum opened this issue Sep 26, 2024 · 3 comments
Open

Intercept resolution of entity type #34765

kjkrum opened this issue Sep 26, 2024 · 3 comments

Comments

@kjkrum
Copy link

kjkrum commented Sep 26, 2024

IMaterializationInterceptor allows the interception of individual entity materialization. Conceptually there must be a preceding step where EF resolves the entity type that a database row will be materialized into. It may be useful to intercept that type resolution.

My use case for this feature would be to examine authorization attributes on the entity type and throw an exception if the current user is not authorized to access that entity type. I'm currently doing this experimentally with an IMaterializationInterceptor. This feature request is based on the possibly incorrect assumption that type resolution only occurs once for a result set, as opposed to materialization which occurs once for every row. My entire use case may prove to be a stupid idea, but there may be more legitimate use cases for a type resolution interceptor.

@AndriySvyryd
Copy link
Member

Type resolution does occur once for every row (roughly). Currently this logic is hardcoded but might be possible to do something like this after #32923 is implemented.

@AndriySvyryd AndriySvyryd added this to the Backlog milestone Oct 4, 2024
@roji
Copy link
Member

roji commented Oct 4, 2024

@kjkrum I'd be interested in more context on exactly what you're trying to achieve, i.e. how exactly you would vary the entity type being materialized, and why - there may be simpler ways to achieve the same overall goal.

@kjkrum
Copy link
Author

kjkrum commented Oct 4, 2024

@roji I'm not interested in changing the entity type, only examining its attributes to see if the current user is authorized to load entities of that type. In other words, roughly speaking, table-level permissions. A materialization interceptor works for this, and performance isn't an issue yet, but maybe it could be more efficient.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants