Blogs

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 (DevExpress)
Filed under:
Technorati tags: XAF Cookbook
Bookmark and Share

Comments

 

Dionel Acosta said:

It is possible to add bussines objects (descendant) automatically-directly from db connection. It est, if there anywhere a place and using rigth click can I select a table or a view from db and put it there as a bussines object????

May 13, 2009 10:15 AM
More from DevExpress
Live Chat
Have a pre-sales question?
Need assistance with your evaluation?
We are here to help.
Chat is one of the many ways you can contact members of the DevExpress Team. We are available Monday-Friday between 8:30am and 5:00pm Pacific Time.
If you need additional product information, require pre-sales assistance, or want help with your order, write to us at info@devexpress.com or call us at
+1 (818) 844-3383.