The ObjectMapper .NET Project

Official blog of the AdFactum ObjectMapper .NET

Archive for November, 2006

Attribute: [WeakReferenced]

Posted by Gerhard Stephan on 20th November 2006

The WeakReferenced Abbtribute forces the mapper to use outer joins when joining parent and child table using Virtual Links.

This attribute is always useful if the child property is not a mandatory property of the parent class.

Think about a contact object that has a mandatory firstname and lastname and a salutation enumeration. The salutation enumeration is not mandatory.

    /// <summary>

    /// Descripes a contact

    /// </summary>

    [Table("CONTACTS")]

    public class Contact : ValueObject

    {

        private Salutation salutation;

        private string salutationText;  // get text from db using a virtual link

 

        private string firstName;

        private string lastName;

 

        /// <summary>

        /// Gets or sets the salutation.

        /// </summary>

        /// <value>The salutation.</value>

        public Salutation Salutation

        {

            get { return salutation; }

            set { salutation = value; }

        }

 

        /// <summary>

        /// Gets or sets the salutation text.

        /// </summary>

        /// <value>The salutation text.</value>

        [VirtualLink(typeof(SalutationText), "Value", "Key", "Salutation")]

        public string SalutationText

        {

            get { return salutationText; }

            set { salutationText = value; }

        }

 

        /// <summary>

        /// Gets or sets the name of the first.

        /// </summary>

        /// <value>The name of the first.</value>

        [Required]

        [PropertyLength(50)]

        public string FirstName

        {

            get { return firstName; }

            set { firstName = value; }

        }

 

        /// <summary>

        /// Gets or sets the name of the last.

        /// </summary>

        /// <value>The name of the last.</value>

        [Required]

        [PropertyLength(50)]

        public string LastName

        {

            get { return lastName; }

            set { lastName = value; }

        }

    }

 

The salutation enumeration looks like this:

    /// <summary>

    /// Salutation

    /// </summary>

    public enum Salutation

    {

        None,

       

        DearMr,

        DearMrs,

        MyFriend

    }

 

And last but not least, the text corresponding to that enumeration will be retrieved by a virtual link using database joins.

 

    /// <summary>

    /// Static texts for salutation

    /// </summary>

    [StaticData]

    [WeakReferenced]

    public class SalutationText : ValueObject

    {

        private Salutation  key;

        private string      value;

 

        public Salutation Key

        {

            get { return key; }

            set { key = value; }

        }

 

        public string Value

        {

            get { return value; }

            set { this.value = value; }

        }

    }

 

When selecting the contact the SQL looks like that:

SELECT contacts.*, v1.VALUE AS salutationtext

  FROM contacts LEFT OUTER JOIN salutationtext v1 ON contacts.salutation = v1.KEY

 

If you wouldn’t use the attribute [WeakReferenced] a contact without a filled salutation could not be loaded. 
Because of that issue the attribute is very important.

1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5.00 out of 5)
Loading...

Posted in Attributes | 1 Comment »

New Release – ObjectMapper .NET 1.4.1014.0

Posted by Gerhard Stephan on 14th November 2006

Today I updated the minor release version because of a critical bug I fixed. The bug always occurs when trying to store MarkedValueObjects with dependent objects and the hierarchy level FlatObjectWithLinks.

Ok – this sounds unique, but it’s quite a common scenario. Think of a distribution class that owns a list of contacts. You modify the distribution class and save it with hierarchy level FlatObjectWithLinks. In that case the Commit will throw an exception and you have to rollback the transaction. So that bug has been fixed.

As default all conditions are using bind Parameters. A new option within a conditioallows you to switch a condition from bind parameters to native SQL.

Condition.UseBindParameter = false;

That’s sometimes important if you want to use special database features like switching table partitions in oracle.

So wish you a successful time.
Cheers

Gerhard

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...

Posted in Releases | No Comments »

New Release – ObjectMapper .NET 1.3.1002.0

Posted by Gerhard Stephan on 2nd November 2006

This release was made to offer some smaller improvements regarding the sql optimizer used in Oracle 10g.

Because of some lacks within Oracle, the optimizer did not always found the best way to solve SQL requests when working with raw datatypes that are used by GUIDs. Due to this fact we changed the parameter handling from implicit casting GUIDs to explicit casting GUIDs using the method HEXTORAW in oracle.

Second thing is, that it’s not anymore required to give the SubSelect Constructor a condition. Now you can set the paramter to NULL if no condition is needed.

Furthermore we added some smaller improvements. I really can’t remember all of them. But I think they won’t affect you in the work with the ObjectMapper .NET.

Wish you fun with the new version of the ObjectMapper .NET.

Cheers
Gerhard

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...

Posted in Releases | No Comments »