Collection of collections mapping inside the Raven Document

22 views
Skip to first unread message

Jim Baltika

unread,
Mar 11, 2012, 5:22:54 PM3/11/12
to rav...@googlegroups.com
Hi,
I am wondering that is the best way to map entity (in this case Clinician) collections of collections inside document? I attached the JSON example and Index example which I started. Its easy for collection with primitive values, but more complex mapping is still mystery for my as I am just growing wings as Raven DB does too :) Any advice? Thanks in advance.

The Lucene query would be something like tahat: 
          IsAcceptingNewPatients: true AND DepartmentsName: Optometry

Assume that  C# property SpecializationsAndDepartments=>Departments=> mapped to DepartmentName 

{
  "Languages": [
    "Spanish"
  ],
  "SpecializationsAndDepartments": [
    {
      "Name": "Braintree",
      "Specializations": [],
      "Departments": [
        "Optometry"
      ]
    },
    {
      "Name": "Quincy",
      "Specializations": [],
      "Departments": [
        "Optometry"
      ]
    }
  ],
  "ClinicianId": 4796,
  "LastName": "beam",
  "FirstName": "jim",
  "Gender": "M",
  "ProfessionalDegrees": [
    "OD"
  ],
  "ProfessionalTitles": [
    "Optometrist"
  ],
  "IsPrimaryCarePhysician": false,
  "IsAcceptingNewPatients": false,
  "Uid": "jim-beam-4796"
}

    /// <summary>
    /// The LINQ Query view indexes
    /// </summary>
    public sealed partial class FindClinicianById : AbstractIndexCreationTask<Clinician>
    {
        /// <summary>
        /// The Raven Index Name
        /// </summary>
        public static readonly string RavenIndexName = typeof(FindClinicianById).Name;
 
        /// <summary>
        /// Initializes a new instance of the <see cref="FindClinicianById"/> class.
        /// </summary>
        public FindClinicianById()
        {
            Map = documents => from clinician in documents
                               select new
                                   {
                                       clinician.LastName,
                                       clinician.IsPrimaryCarePhysician,
                                       clinician.IsAcceptingNewPatients,
                                       clinician.Gender,
                                       ProfessionalDegree = clinician.ProfessionalDegrees,
                                       Language = clinician.Languages,
                                       DepartmentName = ??????????????????????????????
                                   };
        }
    }

Oren Eini (Ayende Rahien)

unread,
Mar 12, 2012, 3:35:12 AM3/12/12
to rav...@googlegroups.com
       DepartmentName = clinician.SpecializationsAndDepartments.SelectMany(x=>x.Departments)
Reply all
Reply to author
Forward
0 new messages