More in this section

Forums / Developing with Sitefinity / How can I implement complex database structure

How can I implement complex database structure

2 posts, 0 answered
  1. Vitaliy
    Vitaliy avatar
    2 posts
    Registered:
    30 Jun 2011
    25 Nov 2011
    Link to this post
    There is a sample in the Developers Guide which shows the creation of a "product" module. This module stores information about products in the Sitefinity database using data persisting class. But I need to store information about a couple of object of different classes with relations or at least foreign keys. How can i do that?
  2. Roberto
    Roberto avatar
    146 posts
    Registered:
    08 Feb 2008
    25 Nov 2011
    Link to this post
    Hi Mikhail,

    We had this issue aswell, we had a locations module to build that needed to store features for a location.  I am not sure if this has changed, as typically you would look to link objects, but the way we were told to do it was via a tracked list of GUIDs, so in out LocationItem object we had:
    private TrackedList<Guid> services;

    [FieldAlias("services")]
     [DataMember]
     [ReadOnly(true)]
     public IList<Guid> Services
     {
         get
         {
             if(this.services == null)
                 this.services = new TrackedList<Guid>();
             return this.services;
         }
         set
         {
             var pc = this.Services;
             pc.Clear();
             foreach(var id in value)
             {
                 pc.Add(id);
             }
         }
      }

    this allowed us to track the services (ServiceItem is another object in the model) linked to the LocationItem.

    In the fluent mapping, i dont think there was anything special

    locationMapping.HasAssociation(p => p.Services);

    thats all i could see, and it has been a while so i dont think there is anything else.

    Hope that helps a bit.

    Rob

     

     

2 posts, 0 answered