1

I know, it's been asked before.

But there's a very simple way of doing this in WinForms using the MySQL Connector thing from the mysql site. Can I use this with WPF aswell? Or is it just a WinForms thing? I've tried it, but doesn't seem to work.

How can I connect to MYSQL with WPF?

  • 1
    And if it makes a difference, preferably also the ability to do queries with Linq (although not a requirement) –  Feb 04 '11 at 12:37

2 Answers2

3

WPF and MySQL have absolutely nothing to do with each other, and can be used together as much as you like. How you implement this is a choice, but going for a separate Data-layer is always a good option. If you create an interface for the data operations, for example

public interface MyPersonRepository{
    Person GetById(args);
    Person Insert(args);
    Person Update(args);
    void Delete(args);
}

you can implement this interface how you want to, and use the MySQL connector or Entity Framework or even NHibernate to access the data. This way WPF doesn't know what database is used, which it really doesn't need to know in the first place.

RoelF
  • 7,483
  • 5
  • 44
  • 67
1

You could use Entity Framework for this. There's more information on how to use Entity Framework with MySQL in this SO question.

Community
  • 1
  • 1
alex
  • 3,710
  • 32
  • 44