开发者

How to connect to MYSQL with WPF?

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 MYSQ开发者_如何学运维L with WPF?


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜