What does EntityFramework's proxy mean?

.net c# entity-framework orm proxy

Question

I've used EntityFramework as an ORM in my projects and I don't have any problem in using this technology. I heard EntityFramework creates a proxy. I want to know WHAT proxy this ORM creates? What it does? And, when EF creates it? In the other words, what is the meaning of term "proxy" frequently being used in ORM topics.

1
18
1/2/2019 3:53:42 AM

Accepted Answer

A proxy in the ORM world is an automatically generated type that inherits from your domain object type. The proxy represents an instance which has not been populated with data from the database yet, but only knows its own ID. Whenever a property which is mapped to the database is accessed, the proxy subclass will carry out the load from the database, so that the load is transparent to the client code.

Proxies are typically created when you have a relationship property between two entities which is lazily loaded. E.g. when you access the user.Address property, what is really returned is an Address proxy object. Only once you access a property of that object (e.g. user.Address.StreetName) the Address object proper will be loaded.

30
8/25/2011 11:24:42 AM



Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow