none
Dataset concepts RRS feed

  • Question

  • Hello.

    I got into an argument with a friend about the concepts of DataSets.

    Suppose I have an employee entity in my system, should I create an employee class, and a dataset (with employee datatable) or should I just use the dataset and datatables.

    If I want to add an entity that do not exists in my datamodel on the DB, should I create it as a class or can I add it as a datatable to my dataset?

    In other words, should datasets replace my needs in creating base classes for my entities in the system?

    Does it matter if I use web services, ASP.NET or win-forms (or WPF)?

    Monday, March 26, 2007 6:44 AM

All replies

  • Hi,

    Business entities and datasets are two ways for database developements. Let's talk about each solution :

    1- DataSets

    This solution is clear. You create your domain schema in an XSD. Your define your tables, columns, relations,...

    You use DataAdapters to retrieve or update from/to database.

    U can also use Microsoft Application Block as a data access layer.

    2- Business Entities

    Here is more complicated. However, when everything is setup, u will love developping Database applications. You will work with objects, properties and methods.

    The big problem with Business entities is how to mapp them with the database. That means how to convert an object to SQL.

    Many ways :

    - Custom DataAccess Layer : That means u create a separate Library to convert your project business entities to Retrieve/Insert/Update/Delete commands.

    Here an example :

    Business Entity : Class Employee {Id, Name, BirthDate}

    DataAccess Layer :

    class EmployeeDAO {

    void InsertEmployee(Employee Emp)

    void UpdateEmployee (Employee Emp)

    void DeleteEmployee(Employee Emp)

    Employee RetrieveById(int ID)

    List<Employee> RetieveAll()

    ......etc

    - You can also use OR Mapping. There a lot of libraries (Open source or commercial) that perform dynamic mapping. The idea is to create a Xml file that containes a mapping between you database and you business entities. And the ORMapper will generate dynamically for u all the sql at runtime.

    Search on the web for OR Mapping you will be served. See also NHibernate it's the most use Open source OR Mapper.

    As answer for ure second question : "Does it matter if I use web services, ASP.NET or win-forms (or WPF)?" the rsponse is not since all object u work with are serialisable. Datasets are serialisable however u must make uour business entities serialisable by declaring the seiralizable attribute or implemeting ISerializable.

     

    HTH.

    Hayder Marzouk

    Monday, March 26, 2007 7:22 AM