General knowledge
MyGeneration is a .Net code generator tool for mapping database tables and procedures into .NET classes and methods. It supports 12 different database systems including Microsoft SQL, Oracle, IBM DB2, PostgreSQL, MySQL, FireBird and more. MyGeneration presents dOOdads that is a .Net architecture available in C# and VB.NET and capable of supporting any .NET managed data provider. The main reason for using this tool is to simplify the operations on data stored in the database. The dOOdads architecture is clear and easy to use. You can create an SQL queries using .NET in a fast and smart way without writing time-consuming code.
DOOdads architecture supports MVC pattern by automating model creation. The main library, MyGeneration.dOOdads.dll, contains various client entity classes (each one for different database system) from which newly created classes inherit. One class inherits directly through specific client entity class, and it contains general settings for creating model like defining connection string (we can name this class "BaseEntityClass"). Other classes inherit from "BaseEntityClass" (we can name them "Concrete classes") and are used for implementations and extensions of base classes. Finally "base classes" are usually abstract classes generated by myGeneration tool and are "read only" as a rule. We don't change them by ourselves because regenerating can overwrite them.
MyGeneration can generate required classes and procedures using pattern templates. Every template can be set to your own need. MyGeneration supplies a rich set of commonly used templates. To generate classes you have to choose one template from the list, decide which database you want to generate from, select tables and enter namespace that classes will be using. Similar action can be done with stored procedures. You choose database, select tables and choose if you want to generate, create or alter scripts. After generation you run scripts in the database manager and stored procedures are ready to use.
How to add myGeneration dOOdads to Visual Studio Project:
- Install myGeneration program.
You can download it from www.mygenerationsoftware.com.
- Create MyGeneration.dOOdads.dll library.
After installation of myGeneration tool you have to open MyGeneration.doodads solution and build the library (..\MyGeneration\Architectures\dOOdads\CSharp\MyGeneration.dOOdads\). In the DbAdapters folder, open the "Entity" corresponding to your database (e.g. "SqlClientEntity"). Find "Build Action" in "Properties" and set to "Compile". Repeat for the "DynamicQuery" adapter and build the project.
- Add new project (class library) to your existing project in which you want to use myGeneration.
- Add MyGeneration.dOOdads.dll library as a reference.
- Add BaseEntityClass.cs class to the root of the project.
The body of this class can look similar (the key "connectionString" is taken from web.config - read more about Connection String for MS SQL database):
- Create two folders named "Base" and "Concrete".
- Generate base and concrete classes using myGeneration, copy them to the proper folder and add to the project. After copying files check whether every Base class inherits from BaseEntityClass and every Concrete class from Base class.
- Build the class library.
How to use myGeneration dOOdads:
(Examples in C#)
// Load and Save
// Add a new record
// Delete a record
// Delete all found records
// Search Query
// Using TearOff