Hi, I am currently trying to evaluate DataObjects.Net for a new commercial product. I am impressed with what I have read so far but Ii have a particular problem and I was wondering what your (more experienced) opinion would be regarding modelling this particular problem using DataObjects.NET. I need to know how I would efficiently model a relational database whereby I have a field in an "Event" table which defines a "SportType"? This "SportsType" field can hold a link to different sports tables E.g. "FootballEvent", "RubgyEvent", "CricketEvent" and "F1 Event". Each of these Sports tables have different fields specific to that sport. My goal is to be able to generically add sports types in the future as required, yet hold sport specific event data (fields) as part of my Event Entity. Is it possible to use an ORM such as DataObjects.Net to reflect such a relationship / generate the database? I have thrown together a quick C# example to express my intent at a higher level - Please refer to the following Stack Overflow Question for examples regarding my intent: http://stackoverflow.com/questions/2546066/modeling-a-generic-relationship-expressed-in-c-in-a-database Thanks in adavance! This thread was imported from our support forum. The original discussion may contain more detailed answer. Original topic by holsee. |
Your example converted to DO4 must look as follows:
In this case Event<t> instances will be available (= mapped automatically) for all suitable Ts from model. E.g. in this case they'll be:
If you'd like to restrict this to just certain types, you must do the following:
One more note: if you'll add a descendant of e.g. FootballEvent called SpecialFootballEvent, you won't get Event<specialfootballevent> available: DO4 maps only the most generic types in each hierarchy (so if it's possible to map just a root, only it will be mapped). In hierarchy of FootballEvent such a generic type is FootballEvent, so DO4 will map a generic instance of Event<t> just for it. This is logical, because:
|