What can ORM be used for Access 2007 - 2010? I am after WPF table binding, etc.

I have an outdated database, which is on all sites, it describes specific content in the format "category / subcategory / child". Until now, adding / editing content is either manual work in tables, or a simple Windows Forms sql tool (I created when I started working!).

I would like the Entity Framework style to drag, bind, and trigger encoding using WPF 4.5 and .net 4.5.

I hesitate to use NHibernate, because EF5 is very easy to learn, I understand that Nhibernate works more (although faster than ORM). Are there any alternatives that work well? I try to avoid too much manual tuning if possible. The editor is not a mandatory project, and I cannot justify a lot of additional work on it - but it will facilitate my work over the next 2 years if a good version is compiled.

I know all the arguments against Access very well :) - to exchange this is not an option, at least for a year.

Having searched the StackOverflow site, I don’t see too many questions requiring this, but I apologize if I missed a good one!

Update: I think I should clarify my question a bit, since in fact what I needed to get at what code generation so that I did not need to manually collect all the classes for the Access database. From what I see, Dapper's job is efficiency, but different from code generation. Based on the thinking of the structure of entities, I can see where I have somewhat connected the tasks in my thinking :). So, in addition to welding my own - does anyone know a good code gene to use with Access. This I can marry Dapper :).

+6
source share
4 answers

You cannot use the Entity Framework because it does not work with Access databases.

You can use NHibernate with MS Access, although NH does not support Access out of the box.
You need NHibernate.JetDriver from NHContrib and here are sample settings for the NH configuration file.

If I recall correctly, the NH Contrib must be compiled against the exact version of NH that you are using, so you probably need to download the source code and compile it yourself.

Alternatively, you can use one of many micro-ORMs, such as Qaru own Dapper .

Dapper is database independent, so it can connect to everything, including Access. Quote from the official website:

Will it work with my db provider?
Dapper does not have specific implementation details for a specific database; it works in all .net ado providers including sqlite, sqlce, firebird, oracle, MySQL, and SQL Server

The disadvantage is that since Dapper is a DB agnostic, you need to implement some useful properties like paging .


EDIT:

IMO Dapper - in "pretty simple for quick transition."
Take a look at this:
( full demo project here )

using System; using System.Data.OleDb; using Dapper; namespace DapperExample { class Program { static void Main(string[] args) { using (var con = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=test.mdb")) { var list = con.Query<Product>("select * from products"); Console.WriteLine("map to a strongly typed list:"); foreach (var item in list) { Console.WriteLine(item.ProductNumber + " : " + item.Description); } Console.WriteLine(); var list2 = con.Query("select * from products"); Console.WriteLine("map to a list of dynamic objects:"); foreach (var item in list2) { Console.WriteLine(item.ProductNumber + " : " + item.Description); } Console.ReadLine(); } } } public class Product { public string ProductNumber { get; set; } public string Description { get; set; } } } 

There are two different requests in this code example.

The first displays a strongly typed list, for example. the result is IEnumerable<Product> . Of course, he needs a Product class that he can map.

The second query returns IEnumerable<Dynamic> (> = .NET 4.0), which means that properties are evaluated on the fly, and you do not need to define the class before, but the disadvantage is that you lose type safety (and IntelliSense).
My personal opinion is that security of the missing type is a transaction breaker for me (I prefer the first query syntax), but maybe this is something for you.

+7
source

Hate to resurrect the old thread, but I recently created a WPF project using PetaPoco, micro-ORM, with MS Access, so I decided to share my implementation.

To add MS Access support to PetaPoco, you just need to add a couple of bits of code:

First add the AccessDatabaseType class. All DataBaseType classes are at the end of the PetaPoco.cs file. Just add a new class after SqlServerDatabaseType.

 class AccessDatabaseType : DatabaseType { public override object ExecuteInsert(Database db, IDbCommand cmd, string PrimaryKeyName) { db.ExecuteNonQueryHelper(cmd); return db.ExecuteScalar<object>("SELECT @@@IDENTITY AS NewID;"); } } 

Next, modify PetaPoco.Internal.DatabaseType.Resolve () to support AccessDatabaseType. (This code assumes that you are using the Jet OLEDB provider)

 public static DatabaseType Resolve(string TypeName, string ProviderName) { //... if (ProviderName.IndexOf("Oledb", StringComparison.InvariantCultureIgnoreCase) >= 0) return Singleton<AccessDatabaseType>.Instance; // Assume SQL Server return Singleton<SqlServerDatabaseType>.Instance; } 

Finally, to create an instance of PetaPoco, use this:

 Db = New PetaPoco.Database("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\db.mdb", "System.Data.Oledb") 

Limitations:

  • PetaPoco assumes that your primary keys are autonumber / identity fields. If you have a PC that is not autonomous, or you have a composite PC, you will need to implement your own insert and save logic.
  • I do not need paging in my application, so I did not implement it.
+5
source

We use the Entity Framework Provider . Thus, we can easily transfer to another database later.

It does not have all the restrictions mentioned above, and works great.

0
source

Tortuga Chain fully supports Access.

https://docevaad.imtqy.com/Chain/Introduction.htm

0
source

All Articles