I've been playing with RavenDB recently and there is something that is annoying me a little.
I have an entity object with a series of value objects, e.g.
class Foo
{
IList<Bar> Bars { get; set; }
}
There are a number of times when I want to pass an object of type Bar into a method/class but at some point want to reference back to the parent entity. In the world of NHibernate that's really easy if I configure it with a 1..* relationship, e.g.
class Bar
{
Foo Foo { get; set; }
}
However RavenDb doesn't really like that which results in me having to create methods like:
void DoSomething(Foo foo, Bar bar)
{
Console.WriteLine(foo);
Console.WriteLine(bar);
}
rather than
void DoSomething(Bar bar)
{
Console.WriteLine(bar.Foo);
Console.WriteLine(bar);
}
Is there any way to achieve this with RavenDb?
I realise that RavenDb (And document databases in general) promote a different way of thinking about dealing with entities, if this is just a case of me being spending too long in the relational/normalised world could anyone explain how I should be structuring my code in a more document db way?