Typed Datasets provide another layer of abstraction where you can separate data layer from business layer. Typed Datasets can represent database schema and provide strongly typed data elements, referential integrity and data constraints.
But typed datasets are limited and any changes in database schema necessitates changing one or more datasets that reference the tables/views etc.
Several free tools have been developed and refined over the years to automatically generate data layer, providing ways to retrieve data from the database, building objects, persisting them and then updating the data in the database. This family of tools is generally called Object Relational Mapping Tools or simply Code Generators. Some ORM tools are obviously more powerful and easy to use than others, but they work by analyzing your database schema and generating classes that are representative of your database tables, view, stored procedures or user defined functions. In essence, these tools build a collection of classes with each column represented as a property.
Maintaining and updating data layer becomes very easy. Whenever you make changes to the database schema, you can easily drop the entire data layer, run the tool again to regenerate the data layer in just few minutes.
ORM tools generate one class per table and create a relationship between multiple classes by creating reference variables similar to the database relationships. There are times where you may want to make custom changes in the generated classes, such as adding a new method or a property. You can easily do so by creating partial classes with the same name. You don't want to modify same classes that are generated by the tool because you would drop and recreate them as your schema changes.
There are several tools out there and I will name a few here that you can review, evaluate and use in your own work. Below is a list of tools that I have used over the years. This is not an exhaustive list and there are possibly some more/better tools out there.
Few ORM Tools
- nHibernate
- Subsonic
- OPF.Net
- OpenAccess ORM
- Wilson O/R Mapper
- Microsoft ADO.NET Entity Framework (Available with Framework 3.5 and up)
Most of these tools are quite powerful and easy to use. Some are freeware while others are licensed. Since our focus in this blog is Microsoft and .NET Framework, we will review Entity Framework in more detail in subsequent posts.
Thank you.
No comments:
Post a Comment