Ninja Database Pro
Class Setup
Basic Tasks > Class Setup

Ninja Database can save any public class as long as it has a primary key defined and it has an empty constructor.  There is no required base class to inherit from.  It is not necessary to mark fields and properties as virtual as it is with NHibernate.   In addition to the primary key, there are several other special properties that have functionality.  They are simply defined by their name.  These special fields are all optional.  The only thing required is the primary key.

 

    public class Vendor

    {

        //This is the primary key (See also the Primary Keys topic)

        public int VendorID { get; set; }

 

        //This is not a special field, it is simply a string property

        public string Name { get; set;  }

 

        //Optional. On insert, this property will be set to DateTime.Now

        public DateTime? CreateDate { get; set; }

 

        // Optional. On update, this property will be set to DateTime.Now

        public DateTime? UpdateDate { get; set; }

 

        // Optional. When saving a list of vendors, only vendors with IsDirty == true will be saved

        public bool IsDirty { get; set; }

 

        // Optional. When saving a list of vendors, vendors with IsDeleted == true will be deleted

        public bool IsDeleted { get; set; }

 

        //This will not be stored in the database
        
[IgnoreColumn]

        public string CreditCardNumber { get; set;  }

    }