Skip to content

Custom proxy generation for entities #14554

@mortenbock

Description

@mortenbock

I would like to generate my own proxies for the entities returned by EF.

The particular feature I would like to be able to implement, is similar to the LazyLoading proxies. But instead of lazy loading, I want to throw exceptions when un-loaded navigational properties are accessed.

And example navigational path could be Blog => Post => Comment.

A method that takes a Post as an argument might not know if the Comments list was loaded by the query. So if the Comments property is accessed, I would want my proxy to throw an exception, if there was no Include for that relation in the query.

Currently, the issue is that the property would just be null, which could be interpreted wrongly be the runtime code.

I looked at the LazyLoading implementation, but it seems most of the code required to do this is marked as "Internal, do not use", so I would suggest there was a supported way of doing this. (If there is, I could not find it, but would love to know)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions