0

I have the followin domain objects:

public class Case {
    public virtual Event {get; set;}
}

public class Event {
    public virtual Case {get;set; }
}

I'm using Fluent for mappings.

At the moment I'm using a standard References mapping from the Case side:

References(x => x.Event).Unique();

But I'm at a loss what to do on the other side.

The main problem I have is that I want to perform searches for both cases and events and be able to sort and filter on the related case and events respectively. In order to do that I need to map the relation from both sides right?

I know I could use a HasMany relation on the event side, but then I'd have to change the property to a list or some other collection and I don't really want to do that.

But my question is, isn't there a better more standard way of doing it? Regular 1-to-1 relations doesn't seem to fit the bill since they seem to mandate that you have a common Id.

Grateful for any tips or pointers!

aeliusd
  • 469
  • 7
  • 18
  • I would encourage you, as much as possible, to not use `one-to-one`. I tried to explain my *why* few days ago here http://stackoverflow.com/a/23447340/1679310. My experience is, if some table references other it is many-to-one. Opposite side is one-to-many. It requires some business handling arround, I agree, but at the end it, in cooperation with NHibernate, does better job for us, I'd say... – Radim Köhler May 11 '14 at 14:01
  • Yea that's sort of what I've gathered as well. But just wanted to throw it out there and see if anyone has a good standard solution for this sort of problem :) – aeliusd May 11 '14 at 14:04

1 Answers1

0

The other endpoint should be a many-to-one, not a one-to-many.

Ricardo Peres
  • 13,724
  • 5
  • 57
  • 74