using System;
using Castle.ActiveRecord;

namespace CompositeKeyExample
{
    [Serializable]
    public class UserKey
    {
        private int orgID;
        private int userID;

        [KeyProperty]
        public int OrgID
        {
            get { return orgID; }
            set { orgID = value; }
        }

        [KeyProperty]
        public int UserID
        {
            get { return userID; }
            set { userID = value; }
        }

        public override int GetHashCode()
        {
            return orgID ^ userID;
        }

        public override bool Equals( object obj )
        {
            if ( this == obj )
            {
                return true;
            }
            UserKey key = obj as UserKey;
            if ( key == null )
            {
                return false;
            }
            if ( this.OrgID != key.OrgID || this.UserID != key.UserID )
            {
                return false;
            }
            return true;
        }
    }
}
