Click here to Skip to main content
15,881,797 members
Articles / Desktop Programming / WPF

The WPF-NHibernate Toolkit

Rate me:
Please Sign up or sign in to vote.
4.98/5 (23 votes)
16 Jan 2010CPOL28 min read 158.9K   3.3K   114  
Adapt NHibernate classes to run in WPF
using System;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using VmWrapperDemo.Domain; 

namespace VmWrapperDemo.ViewModel
{
    public class OrderVM : VmObjectBase<Order>
    {
        #region Fields
        
        // Property variables
        /* No property variables in this class. */

        #endregion

        #region Constructors
        
        /// <summary>
        /// Constructor that creates a new domain object and wraps it in 
        /// a view model wrapper.
        /// </summary>
        /// <remarks>
        /// This constructor is used when a view model object is created
        /// by a XAML data binding operation.
        /// </remarks>
        public OrderVM() : this(new Order())
        {
        }

        /// <summary>
        /// Constructor that wraps an existing domain object in a view 
        /// model wrapper.
        /// </summary>
        /// <remarks>
        /// This constructor is used when a view model object is created
        /// as part of the initialization of a view model.
        /// </remarks>
        public OrderVM(Order domainObject) : base(domainObject)
        {
        }

        #endregion

        #region Bindable Properties

		public DateTime Date
        {
            get { return base.DomainObject.Date; }

            set
            {
                base.DomainObject.Date = value;
                base.RaisePropertyChangedEvent("Date");
            }
        }


        public decimal Amount
        {
            get { return base.DomainObject.Amount; }

            set
            {
                base.DomainObject.Amount = value;
                base.RaisePropertyChangedEvent("Amount");
            }
        }
		
        #endregion
    }
}
      

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) Foresight Systems
United States United States
David Veeneman is a financial planner and software developer. He is the author of "The Fortune in Your Future" (McGraw-Hill 1998). His company, Foresight Systems, develops planning and financial software.

Comments and Discussions