Posted by: Swapnil | July 10, 2007

DataSet vs Custom Entity

We have seen at many places we are preferred to use Custom entity classes over Dataset, I came across some useful articles which has reason behind this, and sample code for Base entity and entity collection classes (including non-generic as well as generic(.Net 2.0) version).

On the Way to Mastering ASP.NET: Introducing Custom Entity Classes
http://msdn2.microsoft.com/En-US/library/aa479317.aspx

In brief

Problem with DataSet

Lack of Abstraction

o The first and most obvious reason to consider alternatives is the DataSet’s inability to decouple your code from the database structure.

Weakly-Typed

o DataSets are weakly-typed, which makes them error prone and likely to impact your development effort.

Not Object-Oriented

o DataSets are objects and C# and Visual Basic .NET are object-oriented (OO) languages doesn’t automatically make your usage of them object-oriented. The “hello world” of OO programming is typically a Person class that is sub-classed by an Employee class. DataSets, however, don’t make this type of inheritance, or most other OO techniques, possible (or at least natural/intuitive).

Benefit with Custom Entity Classes

– Take advantage of OO techniques such as inheritance and encapsulation

– You can add custom behavior

– Object-Relational Mapping

– Mapping Custom Collections

– Managing Relationships between two entities in Object oriented way

Advertisements

Responses

  1. […] https://swap.wordpress.com/2007/07/10/dataset-vs-custom-entity/ […]


Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: