views:

73

answers:

0

We use a pesonal design to store modified rows. For the data we need to keep, we use 2 tables; the first with fields that don't change, the second uses soft delete.

+----------+  +---------------+ 
| TableBase|  | Table         | 
+==========+  +===============+ 
| Id       |  | TableId       |
| FieldA   |  | Id            |
+----------+  | ReplacedBy    |
              | FieldB        |
              | FieldC        | 
              +---------------+

Now we have the current classes:

 public abstract class TableBase
 {
  public virtual int Id { get; protected set; }
  public virtual string FieldA {get; set;}
 }

 public class Table: TableBase
 {
  public virtual int TableId { get; protected set; }
  // ReplacedBy is null: not replaced
  public virtual int? ReplacedBy { get; set; }
  public virtual string FieldB {get; set;}
  public virtual string FieldC {get; set;}
 }

Is there a way to map this with Fluent NHibernate? < Join > probably is the better solution, but there is no way to tell that we have to load only when ReplacedBy is null. The Where is ignored by the mapping and is not present in the subclasses.

Mic.