As I embark on the task of converting the Powerbuilder Application to Visual Studio, I follow the usual steps I take when creating a new application. The first step is to create the database, but since this is an existing application, that step has already been taken care of. However, there is a challenge – there are over 200 tables, which means I’ll need to create a considerable number of Business Objects for this. My suggestion is that if you’re using an existing database, you should check if the table is being used. If it’s not, don’t worry about creating its model right now.

In Visual Studio 2008, creating Business Objects has become much easier. Back in VS 05 and earlier, we needed to create models in a verbose manner like the one shown below, which I’m sure many of you have created in the past:

csharp
public class UserInfo { private string _firstName; private string _lastName; private string _fullName; private DateTime _dateOfBirth; public UserInfo() { } public string Firstname { get { return _firstName; } set { _firstName = value; } } public string Lastname { get { return _lastName; } set { _lastName = value; } } public string Fullname { get { return _lastName + "," + _firstName; } set { _fullName = value; } } public DateTime DateOfBirth { get { return _dateOfBirth; } set { _dateOfBirth = value; } } }

Fortunately, in VS 08, Microsoft has made this process much simpler. The same class can now be created as shown below:

csharp
public class UserInfo { public string _firstName{ get; set; } public string _lastName{ get; set; } public string _fullName{ get{ return _lastName + "," + _firstName; } set; } public DateTime _dateOfBirth{ get; set; } public UserInfo() {} }

As you can see, the return and value settings are now implied, making this model much easier to read. You can still expand the getter or setter, as we did with _fullName, but the fact remains that creating Business Objects in VS 08 has become much easier.

Leave a Reply

Your email address will not be published. Required fields are marked *