What is Db2Orm?


Db2Orm is an object-relational mapper (O/RM) framework for .NET applications that works like Entity Framework but is only designed for db2/db400 databases. The IBM solution (EntityFramework.IBM.DB2) only works with tables created by SQL. Unfortunately that does not help in most cases. That's why this library was developed.

How to use Db2Orm?


First, you need the Offergeld.Db2Orm.Tools library to create the desired context and related entities. To accomplish this, the "Tools" library includes a Scaffold-Db2Context command, which runs in the NuGet Package Manager Console.

PM> Scaffold-Db2Context -connection "Driver={Client Access ODBC Driver (32-bit)};System=database.ozv.de;Uid=user;Pwd=password;" -context "MyContext" -tables "testlib.Companies", "testlib.Customer"

In this case, a context named "MyContext" and the entities "Companies" and "Customer" would be generated in the selected project (Standard-Project).


Now you can work with your context as you are used to from EntityFramework/Linq.

Examples:

C# Automatic Image to Text Create Context
  1. var context = new MyContext("Driver={Client Access ODBC Driver (32-bit)};System=database.ozv.com;Uid=user;Pwd=password;");
C# Automatic Image to Text Get Data
  1. var all = context.Companies.ToList();
  2. var namedSascha = context.Customer.Where(w => w.FirstName == "Sascha").ToList();
  3. var onlyFirst = context.Companies.Where(w => w.Name == "Offergeld").FirstOrDefault();
  4. var count = context.Customer.Where(w => w.Age > 20).Count();
  5. var specificFields = context.Customer.Where(w => w.FirstName == "Sascha").Select(s => new { s.LastName, s.Age }).ToList();
C# Automatic Image to Text Add and Delete
  1. var newCompany = new Company() { Name = "IBM" };
  2. context.Companies.Add(newCompany);
  3. var offergeld = context.Companies.Where(w => w.Name == "Offergeld").FirstOrDefault();
  4. context.Companies.Remove(offergeld);

As soon as you want to change, add or delete entities, you need a license key that must be stored in the code. To retrieve data, the key is not needed.

C# Automatic Image to Text License
  1. Db2OrmLicense.Key = "4711";
  2. var offergeld = context.Companies.SingleOrDefault(s => s.Name == "Offergeld");
  3. offergeld.PhoneNumber = 123456789;
  4. //Requires a license key
  5. context.SaveChanges();

How to install Db2Orm?


PM> Install-Package Offergeld.Db2Orm
PM> Install-Package Offergeld.Db2Orm.Tools

Get in contact with us!

If you need a license key or have a question, please write us your message to this email.