This is a migrated thread and some comments may be shown as answers.

Using nested struct as column type

3 Answers 62 Views
Development (API, general questions)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Skywalker
Top achievements
Rank 1
Skywalker asked on 30 Nov 2009, 06:56 PM
Hi,

I defined a struct inside a class. I wish to use that nested struct as a column type.

However, the Forward Mapping window tells me that I should mark the property as Transient, because the used datatype is either not marked as Persistent or is of a non-supported type.

I marked the struct as Persistent, so that should not be the problem.
When I move the struct out of my class, then Open Access gives no problems: it recognizes that I;m using a struct as a column type.

My question is, is it somehow possible to use a nested struct?

Below is a simple code snippet of what I mean by nested struct:

[Persistent]  
public class User  
{  
   // Private fields  
   private Address homeAddress;  
   private Address workAddress;  
 
   // Properties  
   [FieldAlias("homeAddress")]  
   public Address HomeAddress  
   {  
      get { return homeAddress; }  
      set { homeAddress = value; }  
   }  
 
   [FieldAlias("workAddress")]  
   public Address WorkAddress  
   {  
      get { return workAddress; }  
      set { workAddress= value; }  
   }  
 
   /// Nested struct  
   [Persistent]  
   public struct Address  
   {  
      private string streetName;  
      private string houseNumber;  
 
      [FieldAlias("streetName")]  
      public string StreetName  
      {   
         get { return streetName; }   
         set { streetName = value; }   
      }  
 
      [FieldAlias("houseNumber")]  
      public string HouseNumber  
      {   
         get { return houseNumber; }   
         set { houseNumber = value; }   
      }  
   }  

That structure does not seem to be supported, or is there a trick that I can use?
It would be nice if it worked. In my project I have several structs that are hlpers of a certain class, so it would be nice if I wouldn't have to put them in the same namespace as the rest of the entities, but instead isolate them a bit.

Thanks,

Sipke

3 Answers, 1 is accepted

Sort by
0
PetarP
Telerik team
answered on 01 Dec 2009, 05:36 PM
Hello Sipke,

That is just a visual glitch with the forward mapping wizard. If you mark your nested structure with the Persistent attribute and click the Reload button in the Forward mapping wizard everything should work as expected. Even if you are seeing an error for the address field in the User class you would still be able to forward map it.
We are sorry for the inconvenience this might have caused you.

Regards,
Petar
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Skywalker
Top achievements
Rank 1
answered on 01 Dec 2009, 07:32 PM
Hi Petar,

You're right, it does work.
In order to configure the database columns I can simply edit app.config, which is good enough for just a few structs.

Do you have any idea when this glitch will be resolved?

Thanks,
Sipke
0
PetarP
Telerik team
answered on 02 Dec 2009, 10:14 AM
Hello Sipke,

We have scheduled this issue to be fixed. I am not able to provide you with an exact date when this will be available but you should find it in one of our next internal builds.

Best wishes,
Petar
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Development (API, general questions)
Asked by
Skywalker
Top achievements
Rank 1
Answers by
PetarP
Telerik team
Skywalker
Top achievements
Rank 1
Share this question
or