in
Forums
Blogs
Files
Devexpress.Com
ClientCenter
Support Center
DevExpress Channel

Gary's Blog

XAF Cookbook #3 – Manage Your Custom Business Objects

Problem

You wish to create a win form and web form application to manage CRUD operations for your custom business objects.

Solution

Create an application, add a DomainObject, define your object’s properties and XAF will, by default, create a web form and win form application to manage the CRUD operations.

Discussion

Once you have created your XAF application, add a new business object by right clicking on the <solutionName>.Module project and clicking the Add –> New Item… menu option. From the dialog select DomainObject V8.2, name it appropriately and press “Add”.

Next add the properties you require, in this case Name, Address and TelephoneNumber (using the CR template “XPS”) and your code will look like this:-

using System;

using DevExpress.Xpo;

using DevExpress.ExpressApp;
using DevExpress.Persistent.Base;
using DevExpress.Persistent.BaseImpl;
using DevExpress.Persistent.Validation;

namespace XAFCookbook_003.Module {
    [DefaultClassOptions]
    public class Library : BaseObject {
        public Library(Session session) : base(session) { }

        private string _Name;
        public string Name {
            get {
                return _Name;
            }
            set {
                SetPropertyValue("Name", ref _Name, value);
            }
        }

        private string _Address;
        public string Address {
            get {
                return _Address;
            }
            set {
                SetPropertyValue("Address", ref _Address, value);
            }
        }

        private string _TelephoneNumber;
        public string TelephoneNumber {
            get {
                return _TelephoneNumber;
            }
            set {
                SetPropertyValue("TelephoneNumber", ref _TelephoneNumber, value);
            }
        }


    }

}

Now, press F5 to launch your application and you will see that XAF has, by default, created a UI that will allow you to perform CRUD operations on your custom business object.

Technorati tags:
Digg This
Published Sep 03 2008, 11:53 AM by Gary Short (Developer Express)
Filed under:
Technorati tags: XAF Cookbook

Comments

No Comments

Leave a Comment

(required)  
(optional)
(required)  
Verification code: Required
   
Add
Copyright © 1998-2008 Developer Express Inc.
ALL RIGHTS RESERVED