Search code examples
castle-activerecord

Mapping lookup tables


I have several tables that all reference the same lookup table. Is it generally a good idea to attach the BelongsTo attribute to each table that references a FK from a lookup table? Or should I model the foreign keys as a property and simply link the two tables while constructing my detached criteria?


Solution

  • Not sure I understand the question, but if you're asking whether to do this:

    [BelongsTo("id_lookup")]
    public virtual Lookup Lookup {get;set;}
    

    or this:

    [Property("id_lookup")]
    public virtual int Lookup {get;set;}
    

    The answer is: use the first one.