BusinessListBase 3.5 way for fetching Objects

BusinessListBase 3.5 way for fetching Objects

Old forum URL: forums.lhotka.net/forums/t/4957.aspx


Martin Sørensen posted on Tuesday, June 10, 2008

Hey all. I need some help regarding BusinessListBase. I need at collection called Leads containing editable objects Lead.

 

Leads – Collection

                             Lead – Object

 

I’m using Csla 3.5 and I’m not sure about the new way of fetching objects for a collection regarding Child_Fetch, Child_Create, Child_Insert, Child_Update. If I look at PT example they all seem to use another  object Assignment. What about then saving that collection will that not men that whey all make at connection to the Database.

 

Could some post an example for a simple BusinessListBase collection using 3.5 way of fetching object

 

Regards Martin

Philip replied on Wednesday, June 11, 2008


#region "Code Complete .NET"
//<warning>
//Do not change this section. Required by the code complete for code re-generation
//</warning>
//<project>Northwind</project>
//<datasource>Customers</datasource>
//<class>BLBusinessBaseDesigner</class>
//<IsLinq>True</IsLinq>
//<ischild>False</ischild>

#endregion

#region "Class Header Comments"
//* *********************************************************************************
//**
//**   Class Name:  BLCustomer
//**   Class Decription:  Business class. Inherits from the BusinessBase in the CSLA.NET Framework
//**
//************************************************************************************
//**
//**  Date: mercredi 11 juin 2008
//**  Author: x43368
//**
//** ****************************************************************************** */
#endregion

#region "usings"
using CodeComplete.Services;
using System.Collections.Generic;
using System;
using System.Data;
using Csla.Data;
using Csla;
using System.Linq;

using NorthwindDemo.DataLayer;

#endregion

#region "Class Overwrite Settings"
/// <summary>
/// Business Class
/// </summary>
/// <remarks>
/// Use the overwrite section to decide what to re-generate.
/// </remarks>
/// <warning>
/// Do not change the schema of this overwrite section. Required by the code complete for code re-generation
/// </warning>
/// <overwrite_me>Y</overwrite_me>
/// <overwrite_private_variables>N</overwrite_private_variables>
/// <overwrite_public_variables>N</overwrite_public_variables>
/// <overwrite_criteria>N</overwrite_criteria>
#endregion

namespace NorthwindDemo.BusinessLayer
{

    [Serializable()]
    public partial class BLCustomer : BusinessBase<BLCustomer>
    {
        #region "Private Variables"

        private static PropertyInfo<System.String> _CustomerId = RegisterProperty<System.String>(typeof(BLCustomer), new PropertyInfo<System.String>("CustomerId"));

        private static PropertyInfo<System.String> _CompanyName = RegisterProperty<System.String>(typeof(BLCustomer), new PropertyInfo<System.String>("CompanyName"));

        private static PropertyInfo<System.String> _ContactName = RegisterProperty<System.String>(typeof(BLCustomer), new PropertyInfo<System.String>("ContactName"));

        private static PropertyInfo<System.String> _ContactTitle = RegisterProperty<System.String>(typeof(BLCustomer), new PropertyInfo<System.String>("ContactTitle"));

        private static PropertyInfo<System.String> _Address = RegisterProperty<System.String>(typeof(BLCustomer), new PropertyInfo<System.String>("Address"));

        private static PropertyInfo<System.String> _City = RegisterProperty<System.String>(typeof(BLCustomer), new PropertyInfo<System.String>("City"));

        private static PropertyInfo<System.String> _Region = RegisterProperty<System.String>(typeof(BLCustomer), new PropertyInfo<System.String>("Region"));

        private static PropertyInfo<System.String> _PostalCode = RegisterProperty<System.String>(typeof(BLCustomer), new PropertyInfo<System.String>("PostalCode"));

        private static PropertyInfo<System.String> _Country = RegisterProperty<System.String>(typeof(BLCustomer), new PropertyInfo<System.String>("Country"));

        private static PropertyInfo<System.String> _Phone = RegisterProperty<System.String>(typeof(BLCustomer), new PropertyInfo<System.String>("Phone"));

        private static PropertyInfo<System.String> _Fax = RegisterProperty<System.String>(typeof(BLCustomer), new PropertyInfo<System.String>("Fax"));

        private static PropertyInfo<BLCustomerOrderCollection> _OrderCollection = RegisterProperty<BLCustomerOrderCollection>(typeof(BLCustomer), new PropertyInfo<BLCustomerOrderCollection>("OrderCollection"));

        private static PropertyInfo<BLCustomerContactCollection> _ContactCollection = RegisterProperty<BLCustomerContactCollection>(typeof(BLCustomer), new PropertyInfo<BLCustomerContactCollection>("ContactCollection"));

        #endregion
        #region "Public Properties"

        /// <summary>
        /// CustomerId Property
        /// </summary>
        /// <returns>System.String</returns>
        /// <remarks>Set the overwrite flag to Y to re-generate the property</remarks>
        /// <overwrite>Y</overwrite>
        public System.String CustomerId
        {
            get
            {
                return GetProperty<System.String>(_CustomerId);
            }
            set
            {
                SetProperty<System.String>(_CustomerId, value);
            }
        }
        //<end_overwrite>

        /// <summary>
        /// CompanyName Property
        /// </summary>
        /// <returns>System.String</returns>
        /// <remarks>Set the overwrite flag to Y to re-generate the property</remarks>
        /// <overwrite>Y</overwrite>
        public System.String CompanyName
        {
            get
            {
                return GetProperty<System.String>(_CompanyName);
            }
            set
            {
                SetProperty<System.String>(_CompanyName, value);
            }
        }
        //<end_overwrite>

        /// <summary>
        /// ContactName Property
        /// </summary>
        /// <returns>System.String</returns>
        /// <remarks>Set the overwrite flag to Y to re-generate the property</remarks>
        /// <overwrite>Y</overwrite>
        public System.String ContactName
        {
            get
            {
                return GetProperty<System.String>(_ContactName);
            }
            set
            {
                SetProperty<System.String>(_ContactName, value);
            }
        }
        //<end_overwrite>

        /// <summary>
        /// ContactTitle Property
        /// </summary>
        /// <returns>System.String</returns>
        /// <remarks>Set the overwrite flag to Y to re-generate the property</remarks>
        /// <overwrite>Y</overwrite>
        public System.String ContactTitle
        {
            get
            {
                return GetProperty<System.String>(_ContactTitle);
            }
            set
            {
                SetProperty<System.String>(_ContactTitle, value);
            }
        }
        //<end_overwrite>

        /// <summary>
        /// Address Property
        /// </summary>
        /// <returns>System.String</returns>
        /// <remarks>Set the overwrite flag to Y to re-generate the property</remarks>
        /// <overwrite>Y</overwrite>
        public System.String Address
        {
            get
            {
                return GetProperty<System.String>(_Address);
            }
            set
            {
                SetProperty<System.String>(_Address, value);
            }
        }
        //<end_overwrite>

        /// <summary>
        /// City Property
        /// </summary>
        /// <returns>System.String</returns>
        /// <remarks>Set the overwrite flag to Y to re-generate the property</remarks>
        /// <overwrite>Y</overwrite>
        public System.String City
        {
            get
            {
                return GetProperty<System.String>(_City);
            }
            set
            {
                SetProperty<System.String>(_City, value);
            }
        }
        //<end_overwrite>

        /// <summary>
        /// Region Property
        /// </summary>
        /// <returns>System.String</returns>
        /// <remarks>Set the overwrite flag to Y to re-generate the property</remarks>
        /// <overwrite>Y</overwrite>
        public System.String Region
        {
            get
            {
                return GetProperty<System.String>(_Region);
            }
            set
            {
                SetProperty<System.String>(_Region, value);
            }
        }
        //<end_overwrite>

        /// <summary>
        /// PostalCode Property
        /// </summary>
        /// <returns>System.String</returns>
        /// <remarks>Set the overwrite flag to Y to re-generate the property</remarks>
        /// <overwrite>Y</overwrite>
        public System.String PostalCode
        {
            get
            {
                return GetProperty<System.String>(_PostalCode);
            }
            set
            {
                SetProperty<System.String>(_PostalCode, value);
            }
        }
        //<end_overwrite>

        /// <summary>
        /// Country Property
        /// </summary>
        /// <returns>System.String</returns>
        /// <remarks>Set the overwrite flag to Y to re-generate the property</remarks>
        /// <overwrite>Y</overwrite>
        public System.String Country
        {
            get
            {
                return GetProperty<System.String>(_Country);
            }
            set
            {
                SetProperty<System.String>(_Country, value);
            }
        }
        //<end_overwrite>

        /// <summary>
        /// Phone Property
        /// </summary>
        /// <returns>System.String</returns>
        /// <remarks>Set the overwrite flag to Y to re-generate the property</remarks>
        /// <overwrite>Y</overwrite>
        public System.String Phone
        {
            get
            {
                return GetProperty<System.String>(_Phone);
            }
            set
            {
                SetProperty<System.String>(_Phone, value);
            }
        }
        //<end_overwrite>

        /// <summary>
        /// Fax Property
        /// </summary>
        /// <returns>System.String</returns>
        /// <remarks>Set the overwrite flag to Y to re-generate the property</remarks>
        /// <overwrite>Y</overwrite>
        public System.String Fax
        {
            get
            {
                return GetProperty<System.String>(_Fax);
            }
            set
            {
                SetProperty<System.String>(_Fax, value);
            }
        }
        //<end_overwrite>

        /// <summary>
        /// OrderCollection Property
        /// </summary>
        /// <returns>BLCustomerOrderCollection</returns>
        /// <remarks>Set the overwrite flag to Y to re-generate the property</remarks>
        /// <overwrite>Y</overwrite>
        public BLCustomerOrderCollection OrderCollection
        {
            get
            {
                return GetProperty<BLCustomerOrderCollection>(_OrderCollection);
            }
            set
            {
                SetProperty<BLCustomerOrderCollection>(_OrderCollection, value);
            }
        }
        //<end_overwrite>

        /// <summary>
        /// ContactCollection Property
        /// </summary>
        /// <returns>BLCustomerContactCollection</returns>
        /// <remarks>Set the overwrite flag to Y to re-generate the property</remarks>
        /// <overwrite>Y</overwrite>
        public BLCustomerContactCollection ContactCollection
        {
            get
            {
                return GetProperty<BLCustomerContactCollection>(_ContactCollection);
            }
            set
            {
                SetProperty<BLCustomerContactCollection>(_ContactCollection, value);
            }
        }
        //<end_overwrite>

        #endregion
        #region "Business Validation"
        /// <summary>
        /// Builds the business rules
        /// </summary>
        /// <remarks>Set the overwrite flag to Y to re-generate the method</remarks>
        /// <overwrite>Y</overwrite>
        protected override void AddBusinessRules()
        {

            ValidationRules.AddRule<BLCustomer>(ValidateCustomerId<BLCustomer>, "CustomerId");

            ValidationRules.AddRule<BLCustomer>(ValidateCustomerIdExtra<BLCustomer>, "CustomerId");

            ValidationRules.AddRule<BLCustomer>(ValidateCompanyName<BLCustomer>, "CompanyName");

            ValidationRules.AddRule<BLCustomer>(ValidateCompanyNameExtra<BLCustomer>, "CompanyName");

            ValidationRules.AddRule<BLCustomer>(ValidateContactName<BLCustomer>, "ContactName");

            ValidationRules.AddRule<BLCustomer>(ValidateContactNameExtra<BLCustomer>, "ContactName");

            ValidationRules.AddRule<BLCustomer>(ValidateContactTitle<BLCustomer>, "ContactTitle");

            ValidationRules.AddRule<BLCustomer>(ValidateContactTitleExtra<BLCustomer>, "ContactTitle");

            ValidationRules.AddRule<BLCustomer>(ValidateAddress<BLCustomer>, "Address");

            ValidationRules.AddRule<BLCustomer>(ValidateAddressExtra<BLCustomer>, "Address");

            ValidationRules.AddRule<BLCustomer>(ValidateCity<BLCustomer>, "City");

            ValidationRules.AddRule<BLCustomer>(ValidateCityExtra<BLCustomer>, "City");

            ValidationRules.AddRule<BLCustomer>(ValidateRegion<BLCustomer>, "Region");

            ValidationRules.AddRule<BLCustomer>(ValidateRegionExtra<BLCustomer>, "Region");

            ValidationRules.AddRule<BLCustomer>(ValidatePostalCode<BLCustomer>, "PostalCode");

            ValidationRules.AddRule<BLCustomer>(ValidatePostalCodeExtra<BLCustomer>, "PostalCode");

            ValidationRules.AddRule<BLCustomer>(ValidateCountry<BLCustomer>, "Country");

            ValidationRules.AddRule<BLCustomer>(ValidateCountryExtra<BLCustomer>, "Country");

            ValidationRules.AddRule<BLCustomer>(ValidatePhone<BLCustomer>, "Phone");

            ValidationRules.AddRule<BLCustomer>(ValidatePhoneExtra<BLCustomer>, "Phone");

            ValidationRules.AddRule<BLCustomer>(ValidateFax<BLCustomer>, "Fax");

            ValidationRules.AddRule<BLCustomer>(ValidateFaxExtra<BLCustomer>, "Fax");

            ValidationRules.AddRule<BLCustomer>(ValidateOrderCollection<BLCustomer>, "OrderCollection");

            ValidationRules.AddRule<BLCustomer>(ValidateOrderCollectionExtra<BLCustomer>, "OrderCollection");

            ValidationRules.AddRule<BLCustomer>(ValidateContactCollection<BLCustomer>, "ContactCollection");

            ValidationRules.AddRule<BLCustomer>(ValidateContactCollectionExtra<BLCustomer>, "ContactCollection");

        }
        //<end_overwrite>


        /// <summary>
        /// Validates the business rules for the CustomerId Property
        /// </summary>
        /// <param name="target"></param>
        /// <param name="e"></param>
        /// <returns>Boolean</returns>
        /// <remarks>Set the overwrite flag to Y to re-generate the property</remarks>
        /// <overwrite>Y</overwrite>
        private static bool ValidateCustomerId<T>(T target, Csla.Validation.RuleArgs e) where T : BLCustomer
        {

            if (ValidationManager.IsMaxLength(target.GetProperty<System.String>(_CustomerId), 5) == false)
            {
                e.Description = "CustomerId column length must be less  5";
                return false;
            }

            return true;
        }
        //<end_overwrite>

        /// <summary>
        /// Validates the business rules for the CompanyName Property
        /// </summary>
        /// <param name="target"></param>
        /// <param name="e"></param>
        /// <returns>Boolean</returns>
        /// <remarks>Set the overwrite flag to Y to re-generate the property</remarks>
        /// <overwrite>Y</overwrite>
        private static bool ValidateCompanyName<T>(T target, Csla.Validation.RuleArgs e) where T : BLCustomer
        {

            if (ValidationManager.IsMaxLength(target.GetProperty<System.String>(_CompanyName), 40) == false)
            {
                e.Description = "CompanyName column length must be less  40";
                return false;
            }

            return true;
        }
        //<end_overwrite>

        /// <summary>
        /// Validates the business rules for the ContactName Property
        /// </summary>
        /// <param name="target"></param>
        /// <param name="e"></param>
        /// <returns>Boolean</returns>
        /// <remarks>Set the overwrite flag to Y to re-generate the property</remarks>
        /// <overwrite>Y</overwrite>
        private static bool ValidateContactName<T>(T target, Csla.Validation.RuleArgs e) where T : BLCustomer
        {

            if (ValidationManager.IsMaxLength(target.GetProperty<System.String>(_ContactName), 30) == false)
            {
                e.Description = "ContactName column length must be less  30";
                return false;
            }

            return true;
        }
        //<end_overwrite>

        /// <summary>
        /// Validates the business rules for the ContactTitle Property
        /// </summary>
        /// <param name="target"></param>
        /// <param name="e"></param>
        /// <returns>Boolean</returns>
        /// <remarks>Set the overwrite flag to Y to re-generate the property</remarks>
        /// <overwrite>Y</overwrite>
        private static bool ValidateContactTitle<T>(T target, Csla.Validation.RuleArgs e) where T : BLCustomer
        {

            if (ValidationManager.IsMaxLength(target.GetProperty<System.String>(_ContactTitle), 30) == false)
            {
                e.Description = "ContactTitle column length must be less  30";
                return false;
            }

            return true;
        }
        //<end_overwrite>

        /// <summary>
        /// Validates the business rules for the Address Property
        /// </summary>
        /// <param name="target"></param>
        /// <param name="e"></param>
        /// <returns>Boolean</returns>
        /// <remarks>Set the overwrite flag to Y to re-generate the property</remarks>
        /// <overwrite>Y</overwrite>
        private static bool ValidateAddress<T>(T target, Csla.Validation.RuleArgs e) where T : BLCustomer
        {

            if (ValidationManager.IsMaxLength(target.GetProperty<System.String>(_Address), 60) == false)
            {
                e.Description = "Address column length must be less  60";
                return false;
            }

            return true;
        }
        //<end_overwrite>

        /// <summary>
        /// Validates the business rules for the City Property
        /// </summary>
        /// <param name="target"></param>
        /// <param name="e"></param>
        /// <returns>Boolean</returns>
        /// <remarks>Set the overwrite flag to Y to re-generate the property</remarks>
        /// <overwrite>Y</overwrite>
        private static bool ValidateCity<T>(T target, Csla.Validation.RuleArgs e) where T : BLCustomer
        {

            if (ValidationManager.IsMaxLength(target.GetProperty<System.String>(_City), 15) == false)
            {
                e.Description = "City column length must be less  15";
                return false;
            }

            return true;
        }
        //<end_overwrite>

        /// <summary>
        /// Validates the business rules for the Region Property
        /// </summary>
        /// <param name="target"></param>
        /// <param name="e"></param>
        /// <returns>Boolean</returns>
        /// <remarks>Set the overwrite flag to Y to re-generate the property</remarks>
        /// <overwrite>Y</overwrite>
        private static bool ValidateRegion<T>(T target, Csla.Validation.RuleArgs e) where T : BLCustomer
        {

            if (ValidationManager.IsMaxLength(target.GetProperty<System.String>(_Region), 15) == false)
            {
                e.Description = "Region column length must be less  15";
                return false;
            }

            return true;
        }
        //<end_overwrite>

        /// <summary>
        /// Validates the business rules for the PostalCode Property
        /// </summary>
        /// <param name="target"></param>
        /// <param name="e"></param>
        /// <returns>Boolean</returns>
        /// <remarks>Set the overwrite flag to Y to re-generate the property</remarks>
        /// <overwrite>Y</overwrite>
        private static bool ValidatePostalCode<T>(T target, Csla.Validation.RuleArgs e) where T : BLCustomer
        {

            if (ValidationManager.IsMaxLength(target.GetProperty<System.String>(_PostalCode), 10) == false)
            {
                e.Description = "PostalCode column length must be less  10";
                return false;
            }

            return true;
        }
        //<end_overwrite>

        /// <summary>
        /// Validates the business rules for the Country Property
        /// </summary>
        /// <param name="target"></param>
        /// <param name="e"></param>
        /// <returns>Boolean</returns>
        /// <remarks>Set the overwrite flag to Y to re-generate the property</remarks>
        /// <overwrite>Y</overwrite>
        private static bool ValidateCountry<T>(T target, Csla.Validation.RuleArgs e) where T : BLCustomer
        {

            if (ValidationManager.IsMaxLength(target.GetProperty<System.String>(_Country), 15) == false)
            {
                e.Description = "Country column length must be less  15";
                return false;
            }

            return true;
        }
        //<end_overwrite>

        /// <summary>
        /// Validates the business rules for the Phone Property
        /// </summary>
        /// <param name="target"></param>
        /// <param name="e"></param>
        /// <returns>Boolean</returns>
        /// <remarks>Set the overwrite flag to Y to re-generate the property</remarks>
        /// <overwrite>Y</overwrite>
        private static bool ValidatePhone<T>(T target, Csla.Validation.RuleArgs e) where T : BLCustomer
        {

            if (ValidationManager.IsMaxLength(target.GetProperty<System.String>(_Phone), 24) == false)
            {
                e.Description = "Phone column length must be less  24";
                return false;
            }

            return true;
        }
        //<end_overwrite>

        /// <summary>
        /// Validates the business rules for the Fax Property
        /// </summary>
        /// <param name="target"></param>
        /// <param name="e"></param>
        /// <returns>Boolean</returns>
        /// <remarks>Set the overwrite flag to Y to re-generate the property</remarks>
        /// <overwrite>Y</overwrite>
        private static bool ValidateFax<T>(T target, Csla.Validation.RuleArgs e) where T : BLCustomer
        {

            if (ValidationManager.IsMaxLength(target.GetProperty<System.String>(_Fax), 24) == false)
            {
                e.Description = "Fax column length must be less  24";
                return false;
            }

            return true;
        }
        //<end_overwrite>

        /// <summary>
        /// Validates the business rules for the OrderCollection Property
        /// </summary>
        /// <param name="target"></param>
        /// <param name="e"></param>
        /// <returns>Boolean</returns>
        /// <remarks>Set the overwrite flag to Y to re-generate the property</remarks>
        /// <overwrite>Y</overwrite>
        private static bool ValidateOrderCollection<T>(T target, Csla.Validation.RuleArgs e) where T : BLCustomer
        {

            return true;
        }
        //<end_overwrite>

        /// <summary>
        /// Validates the business rules for the ContactCollection Property
        /// </summary>
        /// <param name="target"></param>
        /// <param name="e"></param>
        /// <returns>Boolean</returns>
        /// <remarks>Set the overwrite flag to Y to re-generate the property</remarks>
        /// <overwrite>Y</overwrite>
        private static bool ValidateContactCollection<T>(T target, Csla.Validation.RuleArgs e) where T : BLCustomer
        {

            return true;
        }
        //<end_overwrite>

        #endregion
        #region "Authorization Rules"
        /// <summary>
        /// Checks if a user is authorized to add data
        /// </summary>
        /// <returns>Boolean</returns>
        /// <remarks>Set the overwrite flag to Y to re-generate the method</remarks>
        /// <overwrite>Y</overwrite>
        public static bool CanAddObject()
        {

            return true;

        }
        //<end_overwrite>

        /// <summary>
        /// Checks if a user is authorized to edit data
        /// </summary>
        /// <returns>Boolean</returns>
        /// <remarks>Set the overwrite flag to Y to re-generate the method</remarks>
        /// <overwrite>Y</overwrite>
        public static bool CanEditObject()
        {

            return true;

        }
        //<end_overwrite>

        /// <summary>
        /// Checks if a user is authorized to delete data
        /// </summary>
        /// <returns>Boolean</returns>
        /// <remarks>Set the overwrite flag to Y to re-generate the method</remarks>
        /// <overwrite>Y</overwrite>
        public static bool CanDeleteObject()
        {

            return true;

        }
        //<end_overwrite>

        /// <summary>
        /// Checks if a user is authorized to read data
        /// </summary>
        /// <returns>Boolean</returns>
        /// <overwrite>Y</overwrite>
        public static bool CanGetObject()
        {

            return true;

        }
        //<end_overwrite>

        #endregion

        #region "Factory Methods"

        /// <summary>
        /// Factory method to create a new empty object
        /// </summary>
        /// <returns>BLCustomer object</returns>
        /// <remarks>Set the overwrite flag to Y to re-generate the method</remarks>
        /// <overwrite>Y</overwrite>
        public static BLCustomer NewRecord()
        {
            if (!CanAddObject())
            {
                throw new System.Security.SecurityException("User not authorized to add data");
            }
            return DataPortal.Create<BLCustomer>();
        }
        //<end_overwrite>


        /// <summary>
        /// Factory method to create a new object retrieved from the database
        /// </summary>
        ///<param name="CustomerId"></param>
        /// <returns>BLCustomer object</returns>
        /// <remarks>Set the overwrite flag to Y to re-generate the method</remarks>
        /// <overwrite>Y</overwrite>

        public static BLCustomer GetRecord(System.String CustomerId)
        {
            if (!CanGetObject())
            {
                throw new System.Security.SecurityException("User not authorized to view a data");
            }

            return DataPortal.Fetch<BLCustomer>(new SingleCriteria<BLCustomer, System.String>(CustomerId));

        }
        //<end_overwrite>

        /// <summary>
        /// Factory method to create a new object retrieved from the database
        /// </summary>
        /// <param name="DTO"></param>
        /// <returns>BLCustomer object</returns>
        /// <remarks>Set the overwrite flag to Y to re-generate the method</remarks>
        /// <overwrite>Y</overwrite>

        public static BLCustomer GetRecord(DTCustomer DTOCustomer)
        {
            if (!CanGetObject())
            {
                throw new System.Security.SecurityException("User not authorized to view a data");
            }
            return DataPortal.Fetch<BLCustomer>(DTOCustomer);

        }
        //<end_overwrite>

        /// <summary>
        /// Factory method to delete a record from a database
        /// </summary>
        ///<param name="CustomerId"></param>
        /// <remarks>Set the overwrite flag to Y to re-generate the method</remarks>
        /// <overwrite>Y</overwrite>
        public static void DeleteRecord(System.String CustomerId)
        {
            if (!CanDeleteObject())
            {
                throw new System.Security.SecurityException("User not authorized to delete data");
            }
            DataPortal.Delete((new SingleCriteria<BLCustomer, System.String>(CustomerId)));

        }

        //<end_overwrite>

        /// <summary>
        /// Factory method to save a record from to a database
        /// </summary>
        /// <returns>BLCustomer object</returns>
        /// <remarks>Set the overwrite flag to Y to re-generate the method</remarks>
        /// <overwrite>Y</overwrite>
        public override BLCustomer Save()
        {
            if (IsDeleted && !CanDeleteObject())
                throw new System.Security.SecurityException(
                "User not authorized to delete data");
            else if (IsNew && !CanAddObject())
                throw new System.Security.SecurityException(
                "User not authorized to add data");
            else if (!CanEditObject())
                throw new System.Security.SecurityException(
                "User not authorized to update data");

            return base.Save();
        }
        //<end_overwrite>


        /// <summary>
        /// Class constructor
        /// </summary>
        /// <remarks>Set the overwrite flag to Y to re-generate the method</remarks>
        /// <overwrite>Y</overwrite>

        public BLCustomer()
        {
        }
        //<end_overwrite>


        #endregion
        #region "Data Access"

        //<end_overwrite>
        /// <summary>
        /// Creates a new empty object. Called by the CSLA.NET DataPortal
        /// </summary>
        /// <remarks>Set the overwrite flag to Y to re-generate the method</remarks>
        /// <overwrite>Y</overwrite>

        private void DataPortal_Create()
        {

            LoadProperty<BLCustomerOrderCollection>(_OrderCollection, BLCustomerOrderCollection.NewCollection());

            LoadProperty<BLCustomerContactCollection>(_ContactCollection, BLCustomerContactCollection.NewCollection());

            ValidationRules.CheckRules();
        }
        //<end_overwrite>

        /// <summary>
        /// Creates a new object from tha database. Called by the CSLA.NET DataPortal
        /// </summary>
        /// <param name="criteria"></param>
        /// <remarks>Set the overwrite flag to Y to re-generate the method</remarks>
        /// <overwrite>Y</overwrite>

        private void DataPortal_Fetch(SingleCriteria<BLCustomer, System.String> criteria)
        {

            using (var ctx = ContextManager<NorthwindDataContext>.GetManager("Northwind"))
            {

                var data = (from record in ctx.DataContext.Customers where record.CustomerId == criteria.Value select record).Single();

                MapEntityToObject(data);

            }

            LoadProperty<BLCustomerOrderCollection>(_OrderCollection, BLCustomerOrderCollection.GetChildren(CustomerId));

            LoadProperty<BLCustomerContactCollection>(_ContactCollection, BLCustomerContactCollection.GetChildren(CustomerId));

        }
        //<end_overwrite>

        /// <summary>
        /// Inserts a new record in the database. Called by the CSLA.NET DataPortal
        /// </summary>
        /// <remarks>Set the overwrite flag to Y to re-generate the method</remarks>
        /// <overwrite>Y</overwrite>
        [Transactional(TransactionalTypes.TransactionScope)]
        protected override void DataPortal_Insert()
        {
            using (var ctx = ContextManager<NorthwindDataContext>.GetManager("Northwind"))
            {
                Customer data = new Customer();
                MapObjectoEntity(data);
                ctx.DataContext.Customers.InsertOnSubmit(data);
                ctx.DataContext.SubmitChanges();

 

                FieldManager.UpdateChildren(this);

            }
        }
        //<end_overwrite>

        /// <summary>
        /// Updates a record in the database. Called by the CSLA.NET DataPortal
        /// </summary>
        /// <remarks>Set the overwrite flag to Y to re-generate the method</remarks>
        /// <overwrite>Y</overwrite>
        [Transactional(TransactionalTypes.TransactionScope)]
        protected override void DataPortal_Update()
        {

            using (var ctx = ContextManager<NorthwindDataContext>.GetManager("Northwind"))
            {
                Customer data = (from record in ctx.DataContext.Customers where record.CustomerId == GetProperty<System.String>(_CustomerId) select record).Single();
                MapObjectoEntity(data);
                ctx.DataContext.SubmitChanges();


                FieldManager.UpdateChildren(this);
            }
        }
        //<end_overwrite>

        /// <summary>
        /// Deletes a record in the database. Called by the CSLA.NET DataPortal
        /// </summary>
        /// <param name="criteria"></param>
        /// <remarks>Set the overwrite flag to Y to re-generate the method</remarks>
        /// <overwrite>Y</overwrite>
        [Transactional(TransactionalTypes.TransactionScope)]
        private void DataPortal_Delete(SingleCriteria<BLCustomer, System.String> criteria)
        {
            using (var ctx = ContextManager<NorthwindDataContext>.GetManager("Northwind"))
            {

                IQueryable<Order> Orderdata = from record in ctx.DataContext.Orders where record.CustomerId == criteria.Value select record;
                foreach (Order item in Orderdata)
                {
                    ctx.DataContext.Orders.DeleteOnSubmit(item);
                }

                IQueryable<Contact> Contactdata = from record in ctx.DataContext.CONTACTS where record.CustomerId == criteria.Value select record;
                foreach (Contact item in Contactdata)
                {
                    ctx.DataContext.CONTACTS.DeleteOnSubmit(item);
                }
                Customer data = (from record in ctx.DataContext.Customers where record.CustomerId == criteria.Value select record).Single();
                ctx.DataContext.Customers.DeleteOnSubmit(data);
                ctx.DataContext.SubmitChanges();

            }

        }
        //<end_overwrite>

        /// <summary>
        /// Maps a DTO object to a business object
        /// </summary>
        /// <param name="DTOCustomer"></param>
        /// <remarks>Set the overwrite flag to Y to re-generate the method</remarks>
        /// <overwrite>Y</overwrite>


        private void MapEntityToObject(Customer DTOCustomer)
        {

            LoadProperty<System.String>(_CustomerId, DTOCustomer.CustomerId);
            LoadProperty<System.String>(_CompanyName, DTOCustomer.CompanyName);
            LoadProperty<System.String>(_ContactName, DTOCustomer.ContactName);
            LoadProperty<System.String>(_ContactTitle, DTOCustomer.ContactTitle);
            LoadProperty<System.String>(_Address, DTOCustomer.Address);
            LoadProperty<System.String>(_City, DTOCustomer.City);
            LoadProperty<System.String>(_Region, DTOCustomer.Region);
            LoadProperty<System.String>(_PostalCode, DTOCustomer.PostalCode);
            LoadProperty<System.String>(_Country, DTOCustomer.Country);
            LoadProperty<System.String>(_Phone, DTOCustomer.Phone);
            LoadProperty<System.String>(_Fax, DTOCustomer.Fax);

        }
        //<end_overwrite>


        /// <summary>
        ///  Maps a business object to a DTO object
        /// </summary>
        /// <returns>DTCustomer"></returns>
        /// <remarks>Set the overwrite flag to Y to re-generate the method</remarks>
        /// <overwrite>Y</overwrite>

        private void MapObjectoEntity(Customer DTOCustomer)
        {

            DTOCustomer.CustomerId = GetProperty<System.String>(_CustomerId);
            DTOCustomer.CompanyName = GetProperty<System.String>(_CompanyName);
            DTOCustomer.ContactName = GetProperty<System.String>(_ContactName);
            DTOCustomer.ContactTitle = GetProperty<System.String>(_ContactTitle);
            DTOCustomer.Address = GetProperty<System.String>(_Address);
            DTOCustomer.City = GetProperty<System.String>(_City);
            DTOCustomer.Region = GetProperty<System.String>(_Region);
            DTOCustomer.PostalCode = GetProperty<System.String>(_PostalCode);
            DTOCustomer.Country = GetProperty<System.String>(_Country);
            DTOCustomer.Phone = GetProperty<System.String>(_Phone);
            DTOCustomer.Fax = GetProperty<System.String>(_Fax);
        }
        //<end_overwrite>
        #endregion
        #region "Export"
        /// <summary>
        /// Export Search Data
        /// </summary>
        /// <param name="CompanyName" >System.String</param>

        /// <param name="FileName"></param>
        /// <param name="ExportOption"></param>
        /// <param name="PageFields"></param>
        /// <remarks>Set the overwrite flag to Y to re-generate the method</remarks>
        /// <overwrite>Y</overwrite>
        public static void ExportSearchData(System.String CompanyName, string FileName, ExportManager.ExportFormat ExportOption, System.Collections.Specialized.StringCollection PageFields)
        {
            try
            {
                ConnectionManager.OpenConnection();
                DataSet SearchData = DLCustomer.GetSearchDataSet(CompanyName);
                ExportManager.ExportData(ExportOption, SearchData, FileName, true, PageFields);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                ConnectionManager.CloseConnection();
            }
        }
        //<end_overwrite>

        /// <summary>
        /// Export  Data
        /// </summary>
        /// <param name="CustomerId" >System.String</param>

        /// <param name="FileName"></param>
        /// <param name="ExportOption"></param>
        /// <param name="PageFields"></param>
        /// <remarks>Set the overwrite flag to Y to re-generate the method</remarks>
        /// <overwrite>Y</overwrite>
        public static void ExportData(System.String[] CustomerId, string FileName, ExportManager.ExportFormat ExportOption, System.Collections.Specialized.StringCollection PageFields)
        {
            try
            {
                ConnectionManager.OpenConnection();
                DataSet ExportDataSet = DLCustomer.GetExportDataset(CustomerId);
                ExportManager.ExportData(ExportOption, ExportDataSet, FileName, true, PageFields);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                ConnectionManager.CloseConnection();
            }
        }
        //<end_overwrite>
        /// <summary>
        /// Export Search Data
        /// </summary>
        /// <param name="CompanyName" >System.String</param>

        /// <param name="FileName"></param>
        /// <param name="ExportOption"></param>
        /// <param name="PageFields"></param>
        /// <remarks>Set the overwrite flag to Y to re-generate the method</remarks>
        /// <overwrite>Y</overwrite>
        public static string DownloadSearchData(System.String CompanyName, string FileName, ExportManager.ExportFormat ExportOption, System.Collections.Specialized.StringCollection PageFields)
        {
            try
            {
                ConnectionManager.OpenConnection();
                DataSet SearchData = DLCustomer.GetSearchDataSet(CompanyName);
                FileName = SearchData.Tables[0].TableName;
                return ExportManager.DownloadData(ExportOption, SearchData, PageFields);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                ConnectionManager.CloseConnection();
            }
        }
        //<end_overwrite>

        /// <summary>
        /// Export  Data
        /// </summary>
        /// <param name="CustomerId" >System.String</param>

        /// <param name="FileName"></param>
        /// <param name="ExportOption"></param>
        /// <param name="PageFields"></param>
        /// <remarks>Set the overwrite flag to Y to re-generate the method</remarks>
        /// <overwrite>Y</overwrite>
        public static string DownloadData(System.String[] CustomerId, string FileName, ExportManager.ExportFormat ExportOption, System.Collections.Specialized.StringCollection PageFields)
        {
            try
            {
                ConnectionManager.OpenConnection();
                DataSet ExportDataSet = DLCustomer.GetExportDataset(CustomerId);
                FileName = ExportDataSet.Tables[0].TableName;
                return ExportManager.DownloadData(ExportOption, ExportDataSet, PageFields);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                ConnectionManager.CloseConnection();
            }
        }
        //<end_overwrite>
        #endregion
    }

}

 

#region "Code Complete .NET"
//<warning>
//Do not change this section. Required by the code complete for code re-generation
//</warning>
//<project>Northwind</project>
//<datasource>Orders</datasource>
//<class>BLBusinessBaseDesigner</class>
//<IsLinq>True</IsLinq>
//<ischild>True</ischild>

#endregion

#region "Class Header Comments"
//* *********************************************************************************
//**
//**   Class Name:  BLOrder
//**   Class Decription:  Business class. Inherits from the BusinessBase in the CSLA.NET Framework
//**
//************************************************************************************
//**
//**  Date: mercredi 11 juin 2008
//**  Author: x43368
//**
//** ****************************************************************************** */
#endregion

#region "usings"
using CodeComplete.Services;
using System.Collections.Generic;
using System;
using System.Data;
using Csla.Data;
using Csla;
using System.Linq;

using NorthwindDemo.DataLayer;

#endregion

#region "Class Overwrite Settings"
/// <summary>
/// Business Class
/// </summary>
/// <remarks>
/// Use the overwrite section to decide what to re-generate.
/// </remarks>
/// <warning>
/// Do not change the schema of this overwrite section. Required by the code complete for code re-generation
/// </warning>
/// <overwrite_me>Y</overwrite_me>
/// <overwrite_private_variables>N</overwrite_private_variables>
/// <overwrite_public_variables>N</overwrite_public_variables>
/// <overwrite_criteria>N</overwrite_criteria>
#endregion

namespace NorthwindDemo.BusinessLayer
{

    [Serializable()]
    public partial class BLOrder : BusinessBase<BLOrder>
    {
        #region "Private Variables"

        private static PropertyInfo<System.Int32> _OrderId = RegisterProperty<System.Int32>(typeof(BLOrder), new PropertyInfo<System.Int32>("OrderId"));

        private static PropertyInfo<System.String> _CustomerId = RegisterProperty<System.String>(typeof(BLOrder), new PropertyInfo<System.String>("CustomerId"));

        private static PropertyInfo<System.Nullable<System.Int32>> _EmployeeId = RegisterProperty<System.Nullable<System.Int32>>(typeof(BLOrder), new PropertyInfo<System.Nullable<System.Int32>>("EmployeeId"));

        private static PropertyInfo<Csla.SmartDate> _OrderDate = RegisterProperty<Csla.SmartDate>(typeof(BLOrder), new PropertyInfo<Csla.SmartDate>("OrderDate"));

        private static PropertyInfo<Csla.SmartDate> _RequiredDate = RegisterProperty<Csla.SmartDate>(typeof(BLOrder), new PropertyInfo<Csla.SmartDate>("RequiredDate"));

        private static PropertyInfo<Csla.SmartDate> _ShippedDate = RegisterProperty<Csla.SmartDate>(typeof(BLOrder), new PropertyInfo<Csla.SmartDate>("ShippedDate"));

        private static PropertyInfo<System.Nullable<System.Int32>> _ShipVia = RegisterProperty<System.Nullable<System.Int32>>(typeof(BLOrder), new PropertyInfo<System.Nullable<System.Int32>>("ShipVia"));

        private static PropertyInfo<System.Nullable<System.Decimal>> _Freight = RegisterProperty<System.Nullable<System.Decimal>>(typeof(BLOrder), new PropertyInfo<System.Nullable<System.Decimal>>("Freight"));

        private static PropertyInfo<System.String> _ShipName = RegisterProperty<System.String>(typeof(BLOrder), new PropertyInfo<System.String>("ShipName"));

        private static PropertyInfo<System.String> _ShipAddress = RegisterProperty<System.String>(typeof(BLOrder), new PropertyInfo<System.String>("ShipAddress"));

        private static PropertyInfo<System.String> _ShipCity = RegisterProperty<System.String>(typeof(BLOrder), new PropertyInfo<System.String>("ShipCity"));

        private static PropertyInfo<System.String> _ShipRegion = RegisterProperty<System.String>(typeof(BLOrder), new PropertyInfo<System.String>("ShipRegion"));

        private static PropertyInfo<System.String> _ShipPostalCode = RegisterProperty<System.String>(typeof(BLOrder), new PropertyInfo<System.String>("ShipPostalCode"));

        private static PropertyInfo<System.String> _ShipCountry = RegisterProperty<System.String>(typeof(BLOrder), new PropertyInfo<System.String>("ShipCountry"));

        #endregion
        #region "Public Properties"

        /// <summary>
        /// OrderId Property
        /// </summary>
        /// <returns>System.Int32</returns>
        /// <remarks>Set the overwrite flag to Y to re-generate the property</remarks>
        /// <overwrite>Y</overwrite>
        public System.Int32 OrderId
        {
            get
            {
                return GetProperty<System.Int32>(_OrderId);
            }
            set
            {
                SetProperty<System.Int32>(_OrderId, value);
            }
        }
        //<end_overwrite>

        /// <summary>
        /// CustomerId Property
        /// </summary>
        /// <returns>System.String</returns>
        /// <remarks>Set the overwrite flag to Y to re-generate the property</remarks>
        /// <overwrite>Y</overwrite>
        public System.String CustomerId
        {
            get
            {
                return GetProperty<System.String>(_CustomerId);
            }
            set
            {
                SetProperty<System.String>(_CustomerId, value);
            }
        }
        //<end_overwrite>

        /// <summary>
        /// EmployeeId Property
        /// </summary>
        /// <returns>System.Nullable<System.Int32></returns>
        /// <remarks>Set the overwrite flag to Y to re-generate the property</remarks>
        /// <overwrite>Y</overwrite>
        public System.Nullable<System.Int32> EmployeeId
        {
            get
            {
                return GetProperty<System.Nullable<System.Int32>>(_EmployeeId);
            }
            set
            {
                SetProperty<System.Nullable<System.Int32>>(_EmployeeId, value);
            }
        }
        //<end_overwrite>

        /// <summary>
        /// OrderDate Property
        /// </summary>
        /// <returns>Csla.SmartDate</returns>
        /// <remarks>Set the overwrite flag to Y to re-generate the property</remarks>
        /// <overwrite>Y</overwrite>
        public Csla.SmartDate OrderDate
        {
            get
            {
                return GetProperty<Csla.SmartDate>(_OrderDate);
            }
            set
            {
                SetProperty<Csla.SmartDate>(_OrderDate, value);
            }
        }
        //<end_overwrite>

        /// <summary>
        /// RequiredDate Property
        /// </summary>
        /// <returns>Csla.SmartDate</returns>
        /// <remarks>Set the overwrite flag to Y to re-generate the property</remarks>
        /// <overwrite>Y</overwrite>
        public Csla.SmartDate RequiredDate
        {
            get
            {
                return GetProperty<Csla.SmartDate>(_RequiredDate);
            }
            set
            {
                SetProperty<Csla.SmartDate>(_RequiredDate, value);
            }
        }
        //<end_overwrite>

        /// <summary>
        /// ShippedDate Property
        /// </summary>
        /// <returns>Csla.SmartDate</returns>
        /// <remarks>Set the overwrite flag to Y to re-generate the property</remarks>
        /// <overwrite>Y</overwrite>
        public Csla.SmartDate ShippedDate
        {
            get
            {
                return GetProperty<Csla.SmartDate>(_ShippedDate);
            }
            set
            {
                SetProperty<Csla.SmartDate>(_ShippedDate, value);
            }
        }
        //<end_overwrite>

        /// <summary>
        /// ShipVia Property
        /// </summary>
        /// <returns>System.Nullable<System.Int32></returns>
        /// <remarks>Set the overwrite flag to Y to re-generate the property</remarks>
        /// <overwrite>Y</overwrite>
        public System.Nullable<System.Int32> ShipVia
        {
            get
            {
                return GetProperty<System.Nullable<System.Int32>>(_ShipVia);
            }
            set
            {
                SetProperty<System.Nullable<System.Int32>>(_ShipVia, value);
            }
        }
        //<end_overwrite>

        /// <summary>
        /// Freight Property
        /// </summary>
        /// <returns>System.Nullable<System.Decimal></returns>
        /// <remarks>Set the overwrite flag to Y to re-generate the property</remarks>
        /// <overwrite>Y</overwrite>
        public System.Nullable<System.Decimal> Freight
        {
            get
            {
                return GetProperty<System.Nullable<System.Decimal>>(_Freight);
            }
            set
            {
                SetProperty<System.Nullable<System.Decimal>>(_Freight, value);
            }
        }
        //<end_overwrite>

        /// <summary>
        /// ShipName Property
        /// </summary>
        /// <returns>System.String</returns>
        /// <remarks>Set the overwrite flag to Y to re-generate the property</remarks>
        /// <overwrite>Y</overwrite>
        public System.String ShipName
        {
            get
            {
                return GetProperty<System.String>(_ShipName);
            }
            set
            {
                SetProperty<System.String>(_ShipName, value);
            }
        }
        //<end_overwrite>

        /// <summary>
        /// ShipAddress Property
        /// </summary>
        /// <returns>System.String</returns>
        /// <remarks>Set the overwrite flag to Y to re-generate the property</remarks>
        /// <overwrite>Y</overwrite>
        public System.String ShipAddress
        {
            get
            {
                return GetProperty<System.String>(_ShipAddress);
            }
            set
            {
                SetProperty<System.String>(_ShipAddress, value);
            }
        }
        //<end_overwrite>

        /// <summary>
        /// ShipCity Property
        /// </summary>
        /// <returns>System.String</returns>
        /// <remarks>Set the overwrite flag to Y to re-generate the property</remarks>
        /// <overwrite>Y</overwrite>
        public System.String ShipCity
        {
            get
            {
                return GetProperty<System.String>(_ShipCity);
            }
            set
            {
                SetProperty<System.String>(_ShipCity, value);
            }
        }
        //<end_overwrite>

        /// <summary>
        /// ShipRegion Property
        /// </summary>
        /// <returns>System.String</returns>
        /// <remarks>Set the overwrite flag to Y to re-generate the property</remarks>
        /// <overwrite>Y</overwrite>
        public System.String ShipRegion
        {
            get
            {
                return GetProperty<System.String>(_ShipRegion);
            }
            set
            {
                SetProperty<System.String>(_ShipRegion, value);
            }
        }
        //<end_overwrite>

        /// <summary>
        /// ShipPostalCode Property
        /// </summary>
        /// <returns>System.String</returns>
        /// <remarks>Set the overwrite flag to Y to re-generate the property</remarks>
        /// <overwrite>Y</overwrite>
        public System.String ShipPostalCode
        {
            get
            {
                return GetProperty<System.String>(_ShipPostalCode);
            }
            set
            {
                SetProperty<System.String>(_ShipPostalCode, value);
            }
        }
        //<end_overwrite>

        /// <summary>
        /// ShipCountry Property
        /// </summary>
        /// <returns>System.String</returns>
        /// <remarks>Set the overwrite flag to Y to re-generate the property</remarks>
        /// <overwrite>Y</overwrite>
        public System.String ShipCountry
        {
            get
            {
                return GetProperty<System.String>(_ShipCountry);
            }
            set
            {
                SetProperty<System.String>(_ShipCountry, value);
            }
        }
        //<end_overwrite>

        #endregion
        #region "Business Validation"
        /// <summary>
        /// Builds the business rules
        /// </summary>
        /// <remarks>Set the overwrite flag to Y to re-generate the method</remarks>
        /// <overwrite>Y</overwrite>
        protected override void AddBusinessRules()
        {

            ValidationRules.AddRule<BLOrder>(ValidateOrderId<BLOrder>, "OrderId");

            ValidationRules.AddRule<BLOrder>(ValidateOrderIdExtra<BLOrder>, "OrderId");

            ValidationRules.AddRule<BLOrder>(ValidateCustomerId<BLOrder>, "CustomerId");

            ValidationRules.AddRule<BLOrder>(ValidateCustomerIdExtra<BLOrder>, "CustomerId");

            ValidationRules.AddRule<BLOrder>(ValidateEmployeeId<BLOrder>, "EmployeeId");

            ValidationRules.AddRule<BLOrder>(ValidateEmployeeIdExtra<BLOrder>, "EmployeeId");

            ValidationRules.AddRule<BLOrder>(ValidateOrderDate<BLOrder>, "OrderDate");

            ValidationRules.AddRule<BLOrder>(ValidateOrderDateExtra<BLOrder>, "OrderDate");

            ValidationRules.AddRule<BLOrder>(ValidateRequiredDate<BLOrder>, "RequiredDate");

            ValidationRules.AddRule<BLOrder>(ValidateRequiredDateExtra<BLOrder>, "RequiredDate");

            ValidationRules.AddRule<BLOrder>(ValidateShippedDate<BLOrder>, "ShippedDate");

            ValidationRules.AddRule<BLOrder>(ValidateShippedDateExtra<BLOrder>, "ShippedDate");

            ValidationRules.AddRule<BLOrder>(ValidateShipVia<BLOrder>, "ShipVia");

            ValidationRules.AddRule<BLOrder>(ValidateShipViaExtra<BLOrder>, "ShipVia");

            ValidationRules.AddRule<BLOrder>(ValidateFreight<BLOrder>, "Freight");

            ValidationRules.AddRule<BLOrder>(ValidateFreightExtra<BLOrder>, "Freight");

            ValidationRules.AddRule<BLOrder>(ValidateShipName<BLOrder>, "ShipName");

            ValidationRules.AddRule<BLOrder>(ValidateShipNameExtra<BLOrder>, "ShipName");

            ValidationRules.AddRule<BLOrder>(ValidateShipAddress<BLOrder>, "ShipAddress");

            ValidationRules.AddRule<BLOrder>(ValidateShipAddressExtra<BLOrder>, "ShipAddress");

            ValidationRules.AddRule<BLOrder>(ValidateShipCity<BLOrder>, "ShipCity");

            ValidationRules.AddRule<BLOrder>(ValidateShipCityExtra<BLOrder>, "ShipCity");

            ValidationRules.AddRule<BLOrder>(ValidateShipRegion<BLOrder>, "ShipRegion");

            ValidationRules.AddRule<BLOrder>(ValidateShipRegionExtra<BLOrder>, "ShipRegion");

            ValidationRules.AddRule<BLOrder>(ValidateShipPostalCode<BLOrder>, "ShipPostalCode");

            ValidationRules.AddRule<BLOrder>(ValidateShipPostalCodeExtra<BLOrder>, "ShipPostalCode");

            ValidationRules.AddRule<BLOrder>(ValidateShipCountry<BLOrder>, "ShipCountry");

            ValidationRules.AddRule<BLOrder>(ValidateShipCountryExtra<BLOrder>, "ShipCountry");

        }
        //<end_overwrite>


        /// <summary>
        /// Validates the business rules for the OrderId Property
        /// </summary>
        /// <param name="target"></param>
        /// <param name="e"></param>
        /// <returns>Boolean</returns>
        /// <remarks>Set the overwrite flag to Y to re-generate the property</remarks>
        /// <overwrite>Y</overwrite>
        private static bool ValidateOrderId<T>(T target, Csla.Validation.RuleArgs e) where T : BLOrder
        {

            if (ValidationManager.IsNumeric(target.GetProperty<System.Int32>(_OrderId)) == false)
            {
                e.Description = "OrderId must be numeric value";
                return false;
            }

            return true;
        }
        //<end_overwrite>

        /// <summary>
        /// Validates the business rules for the CustomerId Property
        /// </summary>
        /// <param name="target"></param>
        /// <param name="e"></param>
        /// <returns>Boolean</returns>
        /// <remarks>Set the overwrite flag to Y to re-generate the property</remarks>
        /// <overwrite>Y</overwrite>
        private static bool ValidateCustomerId<T>(T target, Csla.Validation.RuleArgs e) where T : BLOrder
        {

            if (ValidationManager.IsMaxLength(target.GetProperty<System.String>(_CustomerId), 5) == false)
            {
                e.Description = "CustomerId column length must be less  5";
                return false;
            }

            return true;
        }
        //<end_overwrite>

        /// <summary>
        /// Validates the business rules for the EmployeeId Property
        /// </summary>
        /// <param name="target"></param>
        /// <param name="e"></param>
        /// <returns>Boolean</returns>
        /// <remarks>Set the overwrite flag to Y to re-generate the property</remarks>
        /// <overwrite>Y</overwrite>
        private static bool ValidateEmployeeId<T>(T target, Csla.Validation.RuleArgs e) where T : BLOrder
        {

            if (ValidationManager.IsNumeric(target.GetProperty<System.Nullable<System.Int32>>(_EmployeeId)) == false)
            {
                e.Description = "EmployeeId must be numeric value";
                return false;
            }

            return true;
        }
        //<end_overwrite>

        /// <summary>
        /// Validates the business rules for the OrderDate Property
        /// </summary>
        /// <param name="target"></param>
        /// <param name="e"></param>
        /// <returns>Boolean</returns>
        /// <remarks>Set the overwrite flag to Y to re-generate the property</remarks>
        /// <overwrite>Y</overwrite>
        private static bool ValidateOrderDate<T>(T target, Csla.Validation.RuleArgs e) where T : BLOrder
        {

            if (ValidationManager.IsDate(target.GetProperty<SmartDate>(_OrderDate).ToString()) == false)
            {
                e.Description = "OrderDate must be a date";
                return false;
            }

            return true;
        }
        //<end_overwrite>

        /// <summary>
        /// Validates the business rules for the RequiredDate Property
        /// </summary>
        /// <param name="target"></param>
        /// <param name="e"></param>
        /// <returns>Boolean</returns>
        /// <remarks>Set the overwrite flag to Y to re-generate the property</remarks>
        /// <overwrite>Y</overwrite>
        private static bool ValidateRequiredDate<T>(T target, Csla.Validation.RuleArgs e) where T : BLOrder
        {

            if (ValidationManager.IsDate(target.GetProperty<SmartDate>(_RequiredDate).ToString()) == false)
            {
                e.Description = "RequiredDate must be a date";
                return false;
            }

            return true;
        }
        //<end_overwrite>

        /// <summary>
        /// Validates the business rules for the ShippedDate Property
        /// </summary>
        /// <param name="target"></param>
        /// <param name="e"></param>
        /// <returns>Boolean</returns>
        /// <remarks>Set the overwrite flag to Y to re-generate the property</remarks>
        /// <overwrite>Y</overwrite>
        private static bool ValidateShippedDate<T>(T target, Csla.Validation.RuleArgs e) where T : BLOrder
        {

            if (ValidationManager.IsDate(target.GetProperty<SmartDate>(_ShippedDate).ToString()) == false)
            {
                e.Description = "ShippedDate must be a date";
                return false;
            }

            return true;
        }
        //<end_overwrite>

        /// <summary>
        /// Validates the business rules for the ShipVia Property
        /// </summary>
        /// <param name="target"></param>
        /// <param name="e"></param>
        /// <returns>Boolean</returns>
        /// <remarks>Set the overwrite flag to Y to re-generate the property</remarks>
        /// <overwrite>Y</overwrite>
        private static bool ValidateShipVia<T>(T target, Csla.Validation.RuleArgs e) where T : BLOrder
        {

            if (ValidationManager.IsNumeric(target.GetProperty<System.Nullable<System.Int32>>(_ShipVia)) == false)
            {
                e.Description = "ShipVia must be numeric value";
                return false;
            }

            return true;
        }
        //<end_overwrite>

        /// <summary>
        /// Validates the business rules for the Freight Property
        /// </summary>
        /// <param name="target"></param>
        /// <param name="e"></param>
        /// <returns>Boolean</returns>
        /// <remarks>Set the overwrite flag to Y to re-generate the property</remarks>
        /// <overwrite>Y</overwrite>
        private static bool ValidateFreight<T>(T target, Csla.Validation.RuleArgs e) where T : BLOrder
        {

            if (ValidationManager.IsNumeric(target.GetProperty<System.Nullable<System.Decimal>>(_Freight)) == false)
            {
                e.Description = "Freight must be numeric value";
                return false;
            }

            return true;
        }
        //<end_overwrite>

        /// <summary>
        /// Validates the business rules for the ShipName Property
        /// </summary>
        /// <param name="target"></param>
        /// <param name="e"></param>
        /// <returns>Boolean</returns>
        /// <remarks>Set the overwrite flag to Y to re-generate the property</remarks>
        /// <overwrite>Y</overwrite>
        private static bool ValidateShipName<T>(T target, Csla.Validation.RuleArgs e) where T : BLOrder
        {

            if (ValidationManager.IsMaxLength(target.GetProperty<System.String>(_ShipName), 40) == false)
            {
                e.Description = "ShipName column length must be less  40";
                return false;
            }

            return true;
        }
        //<end_overwrite>

        /// <summary>
        /// Validates the business rules for the ShipAddress Property
        /// </summary>
        /// <param name="target"></param>
        /// <param name="e"></param>
        /// <returns>Boolean</returns>
        /// <remarks>Set the overwrite flag to Y to re-generate the property</remarks>
        /// <overwrite>Y</overwrite>
        private static bool ValidateShipAddress<T>(T target, Csla.Validation.RuleArgs e) where T : BLOrder
        {

            if (ValidationManager.IsMaxLength(target.GetProperty<System.String>(_ShipAddress), 60) == false)
            {
                e.Description = "ShipAddress column length must be less  60";
                return false;
            }

            return true;
        }
        //<end_overwrite>

        /// <summary>
        /// Validates the business rules for the ShipCity Property
        /// </summary>
        /// <param name="target"></param>
        /// <param name="e"></param>
        /// <returns>Boolean</returns>
        /// <remarks>Set the overwrite flag to Y to re-generate the property</remarks>
        /// <overwrite>Y</overwrite>
        private static bool ValidateShipCity<T>(T target, Csla.Validation.RuleArgs e) where T : BLOrder
        {

            if (ValidationManager.IsMaxLength(target.GetProperty<System.String>(_ShipCity), 15) == false)
            {
                e.Description = "ShipCity column length must be less  15";
                return false;
            }

            return true;
        }
        //<end_overwrite>

        /// <summary>
        /// Validates the business rules for the ShipRegion Property
        /// </summary>
        /// <param name="target"></param>
        /// <param name="e"></param>
        /// <returns>Boolean</returns>
        /// <remarks>Set the overwrite flag to Y to re-generate the property</remarks>
        /// <overwrite>Y</overwrite>
        private static bool ValidateShipRegion<T>(T target, Csla.Validation.RuleArgs e) where T : BLOrder
        {

            if (ValidationManager.IsMaxLength(target.GetProperty<System.String>(_ShipRegion), 15) == false)
            {
                e.Description = "ShipRegion column length must be less  15";
                return false;
            }

            return true;
        }
        //<end_overwrite>

        /// <summary>
        /// Validates the business rules for the ShipPostalCode Property
        /// </summary>
        /// <param name="target"></param>
        /// <param name="e"></param>
        /// <returns>Boolean</returns>
        /// <remarks>Set the overwrite flag to Y to re-generate the property</remarks>
        /// <overwrite>Y</overwrite>
        private static bool ValidateShipPostalCode<T>(T target, Csla.Validation.RuleArgs e) where T : BLOrder
        {

            if (ValidationManager.IsMaxLength(target.GetProperty<System.String>(_ShipPostalCode), 10) == false)
            {
                e.Description = "ShipPostalCode column length must be less  10";
                return false;
            }

            return true;
        }
        //<end_overwrite>

        /// <summary>
        /// Validates the business rules for the ShipCountry Property
        /// </summary>
        /// <param name="target"></param>
        /// <param name="e"></param>
        /// <returns>Boolean</returns>
        /// <remarks>Set the overwrite flag to Y to re-generate the property</remarks>
        /// <overwrite>Y</overwrite>
        private static bool ValidateShipCountry<T>(T target, Csla.Validation.RuleArgs e) where T : BLOrder
        {

            if (ValidationManager.IsMaxLength(target.GetProperty<System.String>(_ShipCountry), 15) == false)
            {
                e.Description = "ShipCountry column length must be less  15";
                return false;
            }

            return true;
        }
        //<end_overwrite>

        #endregion
        #region "Authorization Rules"
        /// <summary>
        /// Checks if a user is authorized to add data
        /// </summary>
        /// <returns>Boolean</returns>
        /// <remarks>Set the overwrite flag to Y to re-generate the method</remarks>
        /// <overwrite>Y</overwrite>
        public static bool CanAddObject()
        {

            return true;

        }
        //<end_overwrite>

        /// <summary>
        /// Checks if a user is authorized to edit data
        /// </summary>
        /// <returns>Boolean</returns>
        /// <remarks>Set the overwrite flag to Y to re-generate the method</remarks>
        /// <overwrite>Y</overwrite>
        public static bool CanEditObject()
        {

            return true;

        }
        //<end_overwrite>

        /// <summary>
        /// Checks if a user is authorized to delete data
        /// </summary>
        /// <returns>Boolean</returns>
        /// <remarks>Set the overwrite flag to Y to re-generate the method</remarks>
        /// <overwrite>Y</overwrite>
        public static bool CanDeleteObject()
        {

            return true;

        }
        //<end_overwrite>

        /// <summary>
        /// Checks if a user is authorized to read data
        /// </summary>
        /// <returns>Boolean</returns>
        /// <overwrite>Y</overwrite>
        public static bool CanGetObject()
        {

            return true;

        }
        //<end_overwrite>

        #endregion

        #region "Factory Methods"

        /// <summary>
        /// Factory method to create a new empty object
        /// </summary>
        /// <returns>BLOrder object</returns>
        /// <remarks>Set the overwrite flag to Y to re-generate the method</remarks>
        /// <overwrite>Y</overwrite>
        public static BLOrder NewRecord()
        {
            if (!CanAddObject())
            {
                throw new System.Security.SecurityException("User not authorized to add data");
            }
            return DataPortal.Create<BLOrder>();
        }
        //<end_overwrite>


        /// <summary>
        /// Factory method to create a new object retrieved from the database
        /// </summary>
        ///<param name="OrderId"></param>
        /// <returns>BLOrder object</returns>
        /// <remarks>Set the overwrite flag to Y to re-generate the method</remarks>
        /// <overwrite>Y</overwrite>

        public static BLOrder GetRecord(System.Int32 OrderId)
        {
            if (!CanGetObject())
            {
                throw new System.Security.SecurityException("User not authorized to view a data");
            }

            return DataPortal.FetchChild<BLOrder>(new SingleCriteria<BLOrder, System.Int32>(OrderId));

        }
        //<end_overwrite>

        /// <summary>
        /// Factory method to create a new object retrieved from the database
        /// </summary>
        /// <param name="DTO"></param>
        /// <returns>BLOrder object</returns>
        /// <remarks>Set the overwrite flag to Y to re-generate the method</remarks>
        /// <overwrite>Y</overwrite>

        public static BLOrder GetRecord(DTOrder DTOOrder)
        {
            if (!CanGetObject())
            {
                throw new System.Security.SecurityException("User not authorized to view a data");
            }
            return DataPortal.FetchChild<BLOrder>(DTOOrder);

        }
        //<end_overwrite>

        /// <summary>
        /// Factory method to delete a record from a database
        /// </summary>
        ///<param name="OrderId"></param>
        /// <remarks>Set the overwrite flag to Y to re-generate the method</remarks>
        /// <overwrite>Y</overwrite>
        public static void DeleteRecord(System.Int32 OrderId)
        {
            if (!CanDeleteObject())
            {
                throw new System.Security.SecurityException("User not authorized to delete data");
            }
            DataPortal.Delete((new SingleCriteria<BLOrder, System.Int32>(OrderId)));

        }

        //<end_overwrite>

        /// <summary>
        /// Factory method to save a record from to a database
        /// </summary>
        /// <returns>BLOrder object</returns>
        /// <remarks>Set the overwrite flag to Y to re-generate the method</remarks>
        /// <overwrite>Y</overwrite>
        public override BLOrder Save()
        {
            if (IsDeleted && !CanDeleteObject())
                throw new System.Security.SecurityException(
                "User not authorized to delete data");
            else if (IsNew && !CanAddObject())
                throw new System.Security.SecurityException(
                "User not authorized to add data");
            else if (!CanEditObject())
                throw new System.Security.SecurityException(
                "User not authorized to update data");

            return base.Save();
        }
        //<end_overwrite>


        /// <summary>
        /// Class constructor
        /// </summary>
        /// <remarks>Set the overwrite flag to Y to re-generate the method</remarks>
        /// <overwrite>Y</overwrite>

        public BLOrder()
        {
            MarkAsChild();
        }
        //<end_overwrite>


        #endregion
        #region "Data Access"

        //<end_overwrite>
        /// <summary>
        /// Creates a new empty object. Called by the CSLA.NET DataPortal
        /// </summary>
        /// <remarks>Set the overwrite flag to Y to re-generate the method</remarks>
        /// <overwrite>Y</overwrite>

        private void Child_Create()
        {

            ValidationRules.CheckRules();
        }
        //<end_overwrite>

        /// <summary>
        /// Creates a new object from tha database. Called by the CSLA.NET DataPortal
        /// </summary>
        /// <param name="criteria"></param>
        /// <remarks>Set the overwrite flag to Y to re-generate the method</remarks>
        /// <overwrite>Y</overwrite>

        private void Child_Fetch(SingleCriteria<BLOrder, System.Int32> criteria)
        {

            using (var ctx = ContextManager<NorthwindDataContext>.GetManager("Northwind"))
            {

                var data = (from record in ctx.DataContext.Orders where record.OrderId == criteria.Value select record).Single();

                MapEntityToObject(data);

            }

        }
        //<end_overwrite>

        /// <summary>
        /// Inserts a new record in the database. Called by the CSLA.NET DataPortal
        /// </summary>
        /// <remarks>Set the overwrite flag to Y to re-generate the method</remarks>
        /// <overwrite>Y</overwrite>
        [Transactional(TransactionalTypes.TransactionScope)]
        protected void Child_Insert()
        {
            using (var ctx = ContextManager<NorthwindDataContext>.GetManager("Northwind"))
            {
                Order data = new Order();
                MapObjectoEntity(data);
                ctx.DataContext.Orders.InsertOnSubmit(data);
                ctx.DataContext.SubmitChanges();

                LoadProperty<System.Int32>(_OrderId, data.OrderId);


            }
        }
        //<end_overwrite>

        /// <summary>
        /// Updates a record in the database. Called by the CSLA.NET DataPortal
        /// </summary>
        /// <remarks>Set the overwrite flag to Y to re-generate the method</remarks>
        /// <overwrite>Y</overwrite>
        [Transactional(TransactionalTypes.TransactionScope)]
        protected void Child_Update()
        {

            using (var ctx = ContextManager<NorthwindDataContext>.GetManager("Northwind"))
            {
                Order data = (from record in ctx.DataContext.Orders where record.OrderId == GetProperty<System.Int32>(_OrderId) select record).Single();
                MapObjectoEntity(data);
                ctx.DataContext.SubmitChanges();

            }
        }
        //<end_overwrite>

        /// <summary>
        /// Deletes a record in the database. Called by the CSLA.NET DataPortal
        /// </summary>
        /// <param name="criteria"></param>
        /// <remarks>Set the overwrite flag to Y to re-generate the method</remarks>
        /// <overwrite>Y</overwrite>
        [Transactional(TransactionalTypes.TransactionScope)]
        private void Child_DeleteSelf()
        {
            using (var ctx = ContextManager<NorthwindDataContext>.GetManager("Northwind"))
            {
                Order data = (from record in ctx.DataContext.Orders where record.OrderId == OrderId select record).Single();
                ctx.DataContext.Orders.DeleteOnSubmit(data);
                ctx.DataContext.SubmitChanges();

            }

        }
        //<end_overwrite>

        /// <summary>
        /// Maps a DTO object to a business object
        /// </summary>
        /// <param name="DTOOrder"></param>
        /// <remarks>Set the overwrite flag to Y to re-generate the method</remarks>
        /// <overwrite>Y</overwrite>


        private void MapEntityToObject(Order DTOOrder)
        {

            LoadProperty<System.Int32>(_OrderId, DTOOrder.OrderId);
            LoadProperty<System.String>(_CustomerId, DTOOrder.CustomerId);
            LoadProperty<System.Nullable<System.Int32>>(_EmployeeId, DTOOrder.EmployeeId);
            LoadProperty<Csla.SmartDate>(_OrderDate, DTOOrder.OrderDate);
            LoadProperty<Csla.SmartDate>(_RequiredDate, DTOOrder.RequiredDate);
            LoadProperty<Csla.SmartDate>(_ShippedDate, DTOOrder.ShippedDate);
            LoadProperty<System.Nullable<System.Int32>>(_ShipVia, DTOOrder.ShipVia);
            LoadProperty<System.Nullable<System.Decimal>>(_Freight, DTOOrder.Freight);
            LoadProperty<System.String>(_ShipName, DTOOrder.ShipName);
            LoadProperty<System.String>(_ShipAddress, DTOOrder.ShipAddress);
            LoadProperty<System.String>(_ShipCity, DTOOrder.ShipCity);
            LoadProperty<System.String>(_ShipRegion, DTOOrder.ShipRegion);
            LoadProperty<System.String>(_ShipPostalCode, DTOOrder.ShipPostalCode);
            LoadProperty<System.String>(_ShipCountry, DTOOrder.ShipCountry);

        }
        //<end_overwrite>


        /// <summary>
        ///  Maps a business object to a DTO object
        /// </summary>
        /// <returns>DTOrder"></returns>
        /// <remarks>Set the overwrite flag to Y to re-generate the method</remarks>
        /// <overwrite>Y</overwrite>

        private void MapObjectoEntity(Order DTOOrder)
        {

            DTOOrder.OrderId = GetProperty<System.Int32>(_OrderId);
            DTOOrder.CustomerId = GetProperty<System.String>(_CustomerId);
            DTOOrder.EmployeeId = GetProperty<System.Nullable<System.Int32>>(_EmployeeId);
            DTOOrder.OrderDate = GetProperty<Csla.SmartDate>(_OrderDate);
            DTOOrder.RequiredDate = GetProperty<Csla.SmartDate>(_RequiredDate);
            DTOOrder.ShippedDate = GetProperty<Csla.SmartDate>(_ShippedDate);
            DTOOrder.ShipVia = GetProperty<System.Nullable<System.Int32>>(_ShipVia);
            DTOOrder.Freight = GetProperty<System.Nullable<System.Decimal>>(_Freight);
            DTOOrder.ShipName = GetProperty<System.String>(_ShipName);
            DTOOrder.ShipAddress = GetProperty<System.String>(_ShipAddress);
            DTOOrder.ShipCity = GetProperty<System.String>(_ShipCity);
            DTOOrder.ShipRegion = GetProperty<System.String>(_ShipRegion);
            DTOOrder.ShipPostalCode = GetProperty<System.String>(_ShipPostalCode);
            DTOOrder.ShipCountry = GetProperty<System.String>(_ShipCountry);
        }
        //<end_overwrite>
        #endregion
        #region "Export"
        /// <summary>
        /// Export Search Data
        /// </summary>


        /// <param name="FileName"></param>
        /// <param name="ExportOption"></param>
        /// <param name="PageFields"></param>
        /// <remarks>Set the overwrite flag to Y to re-generate the method</remarks>
        /// <overwrite>Y</overwrite>
        public static void ExportSearchData(string FileName, ExportManager.ExportFormat ExportOption, System.Collections.Specialized.StringCollection PageFields)
        {
            try
            {
                ConnectionManager.OpenConnection();
                DataSet SearchData = DLOrder.GetSearchDataSet();
                ExportManager.ExportData(ExportOption, SearchData, FileName, true, PageFields);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                ConnectionManager.CloseConnection();
            }
        }
        //<end_overwrite>

        /// <summary>
        /// Export  Data
        /// </summary>
        /// <param name="OrderId" >System.Int32</param>

        /// <param name="FileName"></param>
        /// <param name="ExportOption"></param>
        /// <param name="PageFields"></param>
        /// <remarks>Set the overwrite flag to Y to re-generate the method</remarks>
        /// <overwrite>Y</overwrite>
        public static void ExportData(System.Int32[] OrderId, string FileName, ExportManager.ExportFormat ExportOption, System.Collections.Specialized.StringCollection PageFields)
        {
            try
            {
                ConnectionManager.OpenConnection();
                DataSet ExportDataSet = DLOrder.GetExportDataset(OrderId);
                ExportManager.ExportData(ExportOption, ExportDataSet, FileName, true, PageFields);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                ConnectionManager.CloseConnection();
            }
        }
        //<end_overwrite>
        /// <summary>
        /// Export Search Data
        /// </summary>


        /// <param name="FileName"></param>
        /// <param name="ExportOption"></param>
        /// <param name="PageFields"></param>
        /// <remarks>Set the overwrite flag to Y to re-generate the method</remarks>
        /// <overwrite>Y</overwrite>
        public static string DownloadSearchData(string FileName, ExportManager.ExportFormat ExportOption, System.Collections.Specialized.StringCollection PageFields)
        {
            try
            {
                ConnectionManager.OpenConnection();
                DataSet SearchData = DLOrder.GetSearchDataSet();
                FileName = SearchData.Tables[0].TableName;
                return ExportManager.DownloadData(ExportOption, SearchData, PageFields);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                ConnectionManager.CloseConnection();
            }
        }
        //<end_overwrite>

        /// <summary>
        /// Export  Data
        /// </summary>
        /// <param name="OrderId" >System.Int32</param>

        /// <param name="FileName"></param>
        /// <param name="ExportOption"></param>
        /// <param name="PageFields"></param>
        /// <remarks>Set the overwrite flag to Y to re-generate the method</remarks>
        /// <overwrite>Y</overwrite>
        public static string DownloadData(System.Int32[] OrderId, string FileName, ExportManager.ExportFormat ExportOption, System.Collections.Specialized.StringCollection PageFields)
        {
            try
            {
                ConnectionManager.OpenConnection();
                DataSet ExportDataSet = DLOrder.GetExportDataset(OrderId);
                FileName = ExportDataSet.Tables[0].TableName;
                return ExportManager.DownloadData(ExportOption, ExportDataSet, PageFields);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                ConnectionManager.CloseConnection();
            }
        }
        //<end_overwrite>
        #endregion
    }

}

Martin Sørensen replied on Wednesday, June 11, 2008

 Thanks… I will take a look at it ;o)

Regards Martin

Copyright (c) Marimer LLC