0

I have the following problem: In my Application I have to connect to an Access Database - yeah, I know that Access isn't a great database - but I have to use it.

The Application will be written in WPF, with the MVVM Light Toolkit and "NHibernate".

How do I connect "NHibernate" with the MVVM Light Toolkit? Do I use the Hibernate Entities as "MVVM" Models? And what's the best place to store user settings which are only need on runtime?

Hamlet Hakobyan
  • 32,965
  • 6
  • 52
  • 68
MaxBec
  • 1
  • 2

2 Answers2

1

how do i connect "NHibernate" with the MVVM Light Toolkit?

Given the Three Layer Architecture, you should differ your GUI from you Database layer.

This means that you shouldn't tie your MVVM framework and your ORM framework together. Among many other disadvantages that this binding will have, it will create high coupling between your GUI and DB, and make it extremely hard to replace, if oneday you'll want to change some of those frameworks.

Do i use the Hibernate Entities as "MVVM" Models

The ultimate loose coupling will be to create a different assembly to store your entities, which you can reference both from you GUI, where they will act as "MVVM" Models, and from your DAL, where they will act as NHibernate Entities.

what's the best place to store user settings which are only need on runtime?

The best place to store user settings are in the App.config file under the <userSettings> tag, which you can also do from the .Settings file under the User scope.

You can easily access them :

var mySetting = Settings.Default.mySetting;

If you want settings that will be available only as the application's lifetime, you can create properties in a static class to hold your settings:

public static class UserSettings
{
    public static string MySetting { get; set; }
}

Hope this helps

Omri Btian
  • 6,499
  • 4
  • 39
  • 65
0

Maybe read this article to get started with the MVVM pattern.

No you would not use the nHibernate entities as ViewModels in you application otherwise you would have a MVM pattern or something like this ;)

It's usually not a good idea to use entities as models exposed to the front end directly because you would mix up data and UI layer...

MichaC
  • 13,104
  • 2
  • 44
  • 56