NavigationProperties and ProxyCreationEnabled

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Oracle
Post Reply
Ansgar
Posts: 10
Joined: Tue 05 Mar 2013 07:25

NavigationProperties and ProxyCreationEnabled

Post by Ansgar » Wed 23 Jul 2014 12:10

Hi all,

I was trying thin following thing:

Code: Select all

      Dim par = New Parent
      Dim ch As New Child
      par.Childs.add(ch)
In the last line an error occured,becausethe navigation property Childs is nothing.
This is the case, because the T4 template provided by DevArt has the following lines:

Code: Select all

 If (Not ProxyCreationEnabled) Then
        #> = New HashSet (Of <#= relationType #>)<#+
      End If
If ProxyCreationEnabled is set to true, all navigationproperties looks like this:

Code: Select all

 Public Overridable Property TABLENAMEs() As ICollection(Of TABLENAME)
If ProxyCreationEnabled is false then it looks like this:

Code: Select all

Public Overridable Property TABLENAMEs() As ICollection(Of TABLENAME) = New HashSet(Of TABLENAME)
I'm sorry, but I don't really understand that design. Could you please explain it to me.

Thanks a lot.

Ansgar

Shalex
Site Admin
Posts: 8366
Joined: Thu 14 Aug 2008 12:44

Re: NavigationProperties and ProxyCreationEnabled

Post by Shalex » Fri 25 Jul 2014 08:50

The dynamic proxy documentation is available at http://msdn.microsoft.com/en-us/data/jj592886.aspx (the "Explicitly creating an instance of a proxy" section demonstates a correct way of creating proxy-class instance).
http://stackoverflow.com/questions/7111 ... 1-and-mvc3
We do not create the HashSet instance. The reason is that a class, which is a descendant from a current class, with overridden navigation properties will be created automatically because of using dynamic proxy classes by Entity Framework itself.
Our implementation assumes that if usage of proxy classes is turned on, a user will use proxy classes.

Post Reply