Take the 2-minute tour ×

I'm using NHibernate 2.2 for my database work and I've faced an issue recently. I have a class called PrescDrugItem which is shown below

public class PrescDrugItem
    public virtual int ItemNumber { get; set; }

    public virtual int AmountIssued { get; set; }

    public virtual string TimePeriod { get; set; }

following is the mapping file

               assembly ="DataContractsLib"
               namespace="DataContractsLib.Prescription" >

  <class name="PrescDrugItem">
    <id name="ItemNumber" type="Int32">
       <generator class="native" />
    <property name="AmountIssued" type="Int32" />
    <property name="TimePeriod" type="String" length="30" />

my problem is, now I need to add another property to the class Item (say ItemTradeName etc), but I dont want it to be saved to the database( because I want to use this new property to store some data temporary). I tried update=false and insert=false in the mapping file but no success yet. Could you guys please tell me is this possible thing to do . Thank you.

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

If it's not to be fetched from the database either, just add it as a normal property of your class and don't map it.

share|improve this answer
thank you for replying Neil, but I thought that it creates another issue when saving the object with the newly added property ? because the nhibernate doesn't know about the property ( no entry in the mapping). I just tested some code and it seems to work very well :) –  Nadun Aug 29 '10 at 10:22
add comment

Your Answer


