New Posts New Posts RSS Feed: Nested Complex Types
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Nested Complex Types

 Post Reply Post Reply
Author
kimj View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 1391
Post Options Post Options   Quote kimj Quote  Post ReplyReply Direct Link To This Post Topic: Nested Complex Types
    Posted: 19-Mar-2008 at 9:37am
Yep, it does look like a code generation error.  Thanks for pointing it out, we'll log the bug report.
Back to Top
danielp37 View Drop Down
Newbie
Newbie


Joined: 18-Mar-2008
Location: United States
Posts: 29
Post Options Post Options   Quote danielp37 Quote  Post ReplyReply Direct Link To This Post Posted: 18-Mar-2008 at 11:06pm
I am trying to use nested complex types and I believe there is a code generation error.
 
Here is what my complex types look like:
 

<ComplexType Name="AddressInfo">

  <Property Name="Street1" Type="String" MaxLength="200" />

  <Property Name="Street2" Type="String" MaxLength="200" />

  <Property Name="City" Type="String" MaxLength="200" />

  <Property Name="State" Type="String" MaxLength="200" />

  <Property Name="PostalCode" Type="String" MaxLength="200" />

  <Property Name="Country" Type="String" MaxLength="200" />

  <Property Name="DateChanged" Type="DateTime" Nullable="true" />

</ComplexType>

<ComplexType Name="ContactInfo">

  <Property Name="Address" Type="DBModel.AddressInfo" Nullable="false" />

  <Property Name="BillingAddress" Type="DBModel.AddressInfo" Nullable="false" />

  <Property Name="Phone" Type="String" Nullable="true" MaxLength="200" />

  <Property Name="PhoneWork" Type="String" Nullable="true" MaxLength="200" />

  <Property Name="PhoneMobile" Type="String" Nullable="true" MaxLength="200" />

  <Property Name="PhoneFax" Type="String" Nullable="true" MaxLength="200" />

  <Property Name="Email" Type="String" Nullable="true" MaxLength="200" />

  <Property Name="NewEmail" Type="String" Nullable="true" MaxLength="200" />

  <Property Name="NewEmailDate" Type="DateTime" Nullable="true" />

  <Property Name="ContactNotes" Type="String" Nullable="true" MaxLength="200" />

</ComplexType>

And this results in the following generated code for the ContactInfo class:


/// <summary>Constructs any non-nullable complex types.</summary>

public ContactInfo() {

this.Address = new Address();

this.BillingAddress = new BillingAddress();

this.Phone = (String)EntityFactory.GetDefaultValue(typeof(String));

this.PhoneWork = (String)EntityFactory.GetDefaultValue(typeof(String));

this.PhoneMobile = (String)EntityFactory.GetDefaultValue(typeof(String));

this.PhoneFax = (String)EntityFactory.GetDefaultValue(typeof(String));

this.Email = (String)EntityFactory.GetDefaultValue(typeof(String));

this.NewEmail = (String)EntityFactory.GetDefaultValue(typeof(String));

this.ContactNotes = (String)EntityFactory.GetDefaultValue(typeof(String));

}

The error is when it tries to instantiate new AddressInfo classes.  Instead of using the typename of AddressInfo, it is using the fieldname of Address and BillingAddress.  I see the same thing in other places in the code where the nested complex types are instantiated.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down