public class Parent_ByChildProperties : AbstractIndexCreationTask<Parent>
{
public class Result
{
public string ParentId { get; set; }
public string ParentName { get; set; }
public IList<int> ChildAges { get; set; }
public IList<string> ChildGenders { get; set; }
}
public Parent_ByChildProperties()
{
Map = funds => from parent in parents
select new
{
ParentId = parent.IdAsGuid,
ParentName = parent.Name,
ChildAges = parent.Children.Select(c => c.Age),
ChildGender = parent.Children.Select(c => c.Gender)
};
}
}
Secondly, our index looks at each Child property in isolation, which means it does not allow us to retrieve a Parent who has a Child that is older than 8 and that same child is also female.
public Parent_ByChildProperties()
{
Map = funds => from parent in parents
from childId in parent.childIds
select new
{
ParentId = parent.Id,
ParentName = parent.Name,
ChildAge = LoadDocument<Child>(childId).Age,
ChildGender = LoadDocument<Child>(childId).Gender
};
}
}
This works fine and searches return the correct parent objects. The only problem is paging. The same issue was raised in this question https://groups.google.com/d/msg/ravendb/l2fkV6szrmQ/AryVlnS7CgAJ and similarly we don't want to force our clients to have to manage the "odd" paging method themselves... they don't care that paging doesn't work as they might expect because we are using RavenDB and it is paging through "Tampered Results". It seemed the only solution to Gluber's question was that he needed to rethink his design.
--
You received this message because you are subscribed to the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Hibernating Rhinos Ltd
Michael Yarichuk l RavenDB Core Team
Office: +972-4-622-7811 l Fax: +972-153-4-622-7811
RavenDB paving the way to "Data Made Simple" http://ravendb.net/
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Hibernating Rhinos Ltd
Oren Eini l CEO l Mobile: + 972-52-548-6969
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+unsubscribe@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+unsubscribe@googlegroups.com.
public class Parent_ByChildProperties : AbstractIndexCreationTask<Parent>
{
public class Result
{
public string ParentId { get; set; }
public string ParentName { get; set; }
public ???? ChildQuery { get; set; }
}
public Parent_ByChildProperties()
{
Map = funds => from parent in parents
select new
{
ParentId = parent.IdAsGuid,
ParentName = parent.Name,
ChildQuery = parent.Children.Select(c => new {c.Age, c.Gender, c.Height, c.EyeColor, c.HairColor})
};
}
}
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+unsubscribe@googlegroups.com.
Note that you can do complex queries on the children, if you know what they are upfront.select new{ChildQuery = parent.Children.Select(c=>new{ c.Age, c.Gender})}And then query using the full object on the client side.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+unsubscribe@googlegroups.com.