Using nested struct as column type

4 posts, 0 answers
  1. Skywalker
    Skywalker avatar
    67 posts
    Member since:
    Sep 2007

    Posted 30 Nov 2009 Link to this post

    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
  2. PetarP
    Admin
    PetarP avatar
    754 posts

    Posted 01 Dec 2009 Link to this post

    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.
  3. DevCraft banner
  4. Skywalker
    Skywalker avatar
    67 posts
    Member since:
    Sep 2007

    Posted 01 Dec 2009 Link to this post

    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
  5. PetarP
    Admin
    PetarP avatar
    754 posts

    Posted 02 Dec 2009 Link to this post

    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.
Back to Top