1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Nolics: Best way to get grandchildren?

Nolics: Best way to get grandchildren?

6 posts, 0 answered
  1. Andy
    Andy avatar
    62 posts
    Registered:
    01 Aug 2008
    12 May 2009
    Link to this post
    I have an object hierarchy: Organisations > Themes > Projects
    ie an Organisation can have many Themes, and a Theme can have many Projects.

    I can easily get all the Projects for a ThemeID.
    However I'm having trouble working out the best way to get all the Projects for an OrganisationID using Nolics.

    What is the best way to do this? I'm struggling with getting my head around how Nolics should be used.

    Thanks! Andy.
  2. Andy
    Andy avatar
    62 posts
    Registered:
    01 Aug 2008
    13 May 2009
    Link to this post
    At the moment, I'm doing this in a function with a loop, getting the OrganisationThemes, then adding each ThemeProject to a List<Project> before returning it.

    There must be a better way, surely!?
  3. Vlad
    Vlad avatar
    498 posts
    Registered:
    19 Jun 2017
    16 May 2009
    Link to this post
    Hello Andy,

    Yes, I think this scenario is supported by Nolics. You can use Groups attribute to join data from many tables.
    Please find the infomation about this approch in the Nolics online documentation. The name of the topic is: How to do <subject> in Nolics.net? > Queries or load objects > Load a large set of objects joining data from many tables.


    Best wishes,
    Vlad
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  4. Andy
    Andy avatar
    62 posts
    Registered:
    01 Aug 2008
    26 May 2009
    Link to this post
    I did have a go at creating a group for all three classes in the hierarchy, using the [Groups="GroupName"] syntax on 'relation' and 'link' in the dbclasses, but I couldn't get it to compile. Where should the [Groups] go in the code below?

    dbclass Organisation [TableName = "sf_projects_Organisation"
        primary key string Application [50], guid ID [AutoGenGUID = True]; 
        string OrganisationName[50]; 
        relation Theme(Parent)[] Themes; 
     
    dbclass Theme [TableName = "sf_projects_Theme"
        primary key string Application [50], guid ID [AutoGenGUID = True]; 
        string ThemeName[50]; 
        //guid ParentID; 
        relation Project(Parent)[] Projects; 
         
        link Organisation Parent: Application, guid OrganisationID ; 
     
     
    dbclass Project [TableName = "sf_projects_Project"
        primary key string Application [50], guid ID [AutoGenGUID = True]; 
         
        string Title[50];                     
        string Number[20]; 
        string Status[50];           
        string Description[500];     
        date StartDate[Format="dd/mm/yyyy"]; 
        date EndDate[Format="dd/mm/yyyy"]; 
        int Cost[Nullable=True]; 
             
        link Theme Parent: Application, guid ThemeID; 
        
     


  5. Vlad
    Vlad avatar
    498 posts
    Registered:
    19 Jun 2017
    26 May 2009
    Link to this post
    Hi Andy,

    I think it should be something like this:
    dbclass Organisation [TableName = "sf_projects_Organisation"]  
    {  
        primary key string Application [50], guid ID [AutoGenGUID = True];  
        string OrganisationName[50];  
        relation Theme(Parent)[] Themes[Groups = "ProjectOrganization"];  
    }  
      
    dbclass Theme [TableName = "sf_projects_Theme"]  
    {  
        primary key string Application [50], guid ID [AutoGenGUID = True];  
        string ThemeName[50];  
        //guid ParentID;  
        relation Project(Parent)[] Projects[Groups = "ProjectOrganization"];  
          
        link Organisation Parent[Groups = "ProjectOrganization"]: Application, guid OrganisationID;  
      
    }  
      
    dbclass Project [TableName = "sf_projects_Project"]  
    {  
        primary key string Application [50], guid ID [AutoGenGUID = True];  
          
        string Title[50];                      
        string Number[20];  
        string Status[50];            
        string Description[500];      
        date StartDate[Format="dd/mm/yyyy"];  
        date EndDate[Format="dd/mm/yyyy"];  
        int Cost[Nullable=True];  
              
        link Theme Parent[Groups = "ProjectOrganization"]: Application, guid ThemeID;  
    }  



    Best wishes,
    Vlad
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  6. Andy
    Andy avatar
    62 posts
    Registered:
    01 Aug 2008
    27 May 2009
    Link to this post
    Thanks Vlad. That compiles better. The syntax of the link and relation keywords confuses me! I had trouble applying the examples of the Nolics help to my code.
Register for webinar
6 posts, 0 answered