AdFactum ObjectMapper .NET Blog

Official blog of the AdFactum ObjectMapper .NET

Attribute: [PrimaryKey]

Posted by Gerhard Stephan on June 11th, 2007

The property PrimaryKey can be used to tag a property that acts as a primary key column for the mapped table. In our classes ValueObject and AutoIncValueObject the Id Property has this attribute already assigned. Therefore this is only important if you write your own base classes or you define interfaces that shall be mapped.

    /// <summary>

    /// Interface that describes a person

    /// </summary>

    public interface IPerson : IValueObject


        /// <summary>

        /// Gets or sets the unique value object id.

        /// </summary>

        /// <value>The unique value object id.</value>


        new int? Id







Note: Combined primary keys are not allowed using the AdFactum ObjectMapper .NET.

Hint: It’s also valid to tag the primary key property with additional attributes, like [PropertyName] or [PropertyLength] to change the database binding.

One Response to “Attribute: [PrimaryKey]”

  1. AdFactum ObjectMapper .NET Blog » Blog Archive » Exception: NoPrimaryKeyFoundException Says:

    […] The NoPrimaryKeyFoundException will be thrown if the user tries to query an entity type which has no valid primary key defined by the PrimaryKey attribute. In case that you use a pre-defined base object like "AutoIncValueObject" or "ValueObject" this exception will never occure. […]

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>