Click here to Skip to main content
15,885,546 members
Articles / Programming Languages / C#

ObjectLounge - An Object-Oriented Database Framework

Rate me:
Please Sign up or sign in to vote.
4.07/5 (8 votes)
30 Jul 2009LGPL310 min read 43.7K   425   45  
Host your Domain Models "Out Of The Box" + No storage or schema needed + Transactions on Domain Models + Validation
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Linq.Mapping;
using Technewlogic.ObjectLounge.Framework.Proxy;
using Technewlogic.ObjectLounge.Framework.Validation;

namespace Technewlogic.ObjectLounge.Test.Model
{
	[Identity("_key")]
	public class Order : BOBase
	{
		#region Constants

		public const string NewID = "New Order";
		public const string CmmsID = "CmmsOrder";
		public const string TimeFliesID = "TimeFliesOrder";
		public const string BillingSystemID = "BillingSystemOrder";

		#endregion

		public Order()
		{
		}

		public Guid _key = Guid.NewGuid();

		public string _orderID;
		public virtual string OrderID
		{
			get
			{
				return _orderID;
			}
			set
			{
				_orderID = value;
				SendPropertyChanged("OrderID");
			}
		}

		public float _price;
		public virtual float Price
		{
			get
			{
				return _price;
			}
			set
			{
				_price = value;
				SendPropertyChanged("Price");
			}
		}

		public DateTime _shippingDate;
		public virtual DateTime ShippingDate
		{
			get
			{
				return _shippingDate;
			}
			set
			{
				_shippingDate = value;
				SendPropertyChanged("ShippingDate");
			}
		}

		[Composition]
		public virtual IList<Material> Materials { get; protected set; }

		// IMP: Vielleicht besser abstract machen, so dass die Implementierung gar nicht vorkommt? Oder AutomaticProperties?
		//protected virtual MasterRef<Customer> _customer { get; set; }
		[MasterRef]
		public virtual Customer Customer
		{
			//get { return _customer.Value; }
			get { throw new NotImplementedException(); }
		}

		//protected AggregateLink<OrderType> _orderType { get; set; }
		[Aggregation]
		public virtual OrderType OrderType
		{
			//get { return _orderType.Value; }
			get { throw new NotImplementedException(); }
			//set { _orderType.Value = value; }
			set { }
		}

		#region Validation

		[ValidationRule]
		protected ValidationResult ValidatePrice()
		{
			if (Context.EnableValidation)
				return ValidationResult.Failure("Price too low!!!");

			return ValidationResult.Success();
		}

		#endregion

		public override string ToString()
		{
			return this.GetType().Name + ": " + OrderID;
		}
	}
}

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 GNU Lesser General Public License (LGPLv3)


Written By
Software Developer (Senior) www.technewlogic.de
Germany Germany
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions