Introducing O/R Mapper and LLBLGen Pro
Author: May

Loading ...
8
Mar
What is O/R Mapper?
O/R Mapper (Object-Relational Mappers) is a programming technique for converting data between incompatible type systems in databases and Object Oriented Programming languages. (# Ref)
What does it do?
The generated code from the O/R Mapper handles all of the steps that you would normally have to code yourself, saving you from having to:
- Find the database server.
- Log in and open a connection to the database server.
- Select the particular database containing the information you want.
- Find the correct table.
- Find the correct row.
- Read all the values for that row.
- Convert every type of value from its SQL data type into the .NET data type while checking and handling the possibility of a null value.
- Present those values in a strongly-typed format, so the consumer knows exactly what kind of object to expect (string, integer, array, etc.) and there are no surprises at run-time.
- Create a container to temporarily hold the values while they are being modified.
- Retrieve data from another row in a related table.
- Manage which values have changed and make appropriate INSERT’s, UPDATE’s, and DELETE’s in the appropriate tables in the database to reflect those changes.
- Close the connection.
What is LLBLGen Pro
LLBLGen Pro is a complete O/R mapper and data-access tier generator for .NET. It generates a data-access tier and business façade/support tier (in C# or VB.NET), using an existing database schema set. The generated .NET code is provided as a Visual Studio.NET project that can be added to a solution or compiled separately. (# Ref + More Info)
LLBLGen Pro Features
A key feature in LLBLGen Pro is dynamically-generated SQL. When retrieving or manipulating data in a database, the SQL script — the code understood by the database — is generated at run-time based off the requested information and dirty flags in each entity’s fields. This enables a generic save entity function on the Data Access Tier to produce different and optimized SQL code each time it is called, optimizing bandwidth usage and database load. (# Ref)
- LLBLGen Pro will completely auto-generate the data access layer. You do not need to do any hand-coding in this layer
- LLBLGen Pro will optionally generate a business logic layer shell for you to get started with your business layer. You do not have to understand the intricacies of inheritance and making custom classes to take advantage of business logic classes; in LLBLGen Pro these classes are intuitively organized, powerful, and infinitely extendable.
- LLBLGen Pro collections and entity objects are bindable, making them extremely easy to add to .NET controls. This can reduce the size of your UI layer.
- Changing the database application and the data access layer without affecting the business logiv and UI layers is actually possible with LLBLGen Pro. If you migrated your database schema and stored procedures to a new database application, refraned from using any database-specific features and your schema matched exactly, you could actually re-generate your LLBLGen Pro data access layer and not make any other changes to your application.
# Ref: Rapic CSharp Windows Development. pp. 17
LLBLGen Pro Objects
- Entities: Every “Row” becomes an “Entity”
- Collections: Every “Table” becomes an “EntityCollection”. Collection classes eliminate the need for DataTable objects and are both strongly typed and bindable.
- Entity relationships: Build into each entity are all relationships in the DB involving that table. You can either get a single entity or an entity collection depending on the type of relationship.
- Typed views: Views in the DB can be wrapped as strongly-typed DataTable. Typed views are read-only; new LLBLGen Pro allows you to add a view from the database as an entity as well as a typed view.
- Typed Lists: Typed lists are the only objects created by LLBLGen Pro that do not correspond one-to-one with DB objects. It’s handy when you need very specific information that does not necessarily correspond to a single table or entity or you only want to grab a subset of information for a given set of table.
- Storedprocedures caller classes: Storedproc that you select will be wrapped in a layer of code. While the parameters of the stored procedures are strongly-typed, the result set is still an untyped DataSet.
Project Types: SelfServicing Vs. Adapter
There are two types of LLBLGen Pro Projects namely – SelfServicing and Adapter.
# In SelfServicing template group, entity objects are responsible for their own persistence (saving their own changes to DB).
# The entity class itself contains logic to know which fields were updated and where to find the database.
# Lazy Loading is useful cos’ it abstracts the specific DB call from the upper layers of code.
# Adapter template group: uses an object called a DataAccessAdapter to interact with DB
# SelfServicing: bundles persistence inside entity objects
# Allows data to load itself automoatically as it is needed without explicit commands.
No related posts.