Class
Code:
[Serializable()]
public class CalendarEvent
{
public virtual DateTime DateCreated {get; set;}
public virtual string Title {get; set;}
public virtual Location Location {get; set;}
public virtual string RRule {get; set;}
public virtual IList<DateTime> Occurrences {get; set;}
// Snip.....
}
Mapping Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
namespace="SocialDance.Core.Domain.Events" assembly="SocialDance.Core">
<class name="CalendarEvent" table="calendar_events">
<id name="Id" type="Int32" unsaved-value="0">
<column name="id" sql-type="int" not-null="true" unique="true"/>
<generator class="native" />
</id>
<property name="Title" type="String">
<column name="title" length="128" sql-type="varchar" not-null="true"/>
</property>
<many-to-one name="Location" type="Location">
<column name="location_id" sql-type="int" not-null="true"/>
</many-to-one>
<property name="RRule" type="String">
<column name="rrule" length="128" sql-type="varchar" not-null="true"/>
</property>
<property name="DateCreated" type="DateTime">
<column name="date_added" sql-type="datetime" not-null="true"/>
</property>
<bag name="Occurrences" table="sd_CalendarEventOccurrences" order-by="start_date ASC">
<key column="event_id"/>
<element column="start_date" type="DateTime"/>
</bag>
</class>
</hibernate-mapping>
The occurrences collection is populated initially based on an ICal RRule specification, but can be manipulated externally. The question is how to efficiently
manipulate the list without having to load all the elements. In other words, i want to be able to add or remove an occurrence without having to load the
parent event and manipulate the Occurrences property (triggering a full load).
The only workaround to this, which is not as semantically nice, is to create a class representing the join (e.g. CalendarEventOccurrence) and
work with those instead.
jbland