Search code examples
c#entity-frameworkdesign-patternslazy-loadingproxy-pattern

Is EF Lazy Loading a real Proxy Pattern?


I know EF use Proxy Pattern to implement lazy loading.

1.Stand Proxy Pattern:

enter image description here

In the proxy pattern,[Proxy] will not be inherited from [RealSubject].

2.EF

In lazy loading,[Proxy] class will be inherited from [RealSubject].

So this is not exact the same as stand Proxy Pattern.

But why they called it Proxy Pattern?


Solution

  • The reason is in the name: it is a pattern, not a rigid rule. It is a concept, which it is described by a known name, so people who know the pattern will understand it although the implementation differs in the details.

    This is valid for patterns in any domain.