MVVM - 型号教程? [英] MVVM - Model Tutorials?

查看:138
本文介绍了MVVM - 型号教程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前,我正在创造C#中的WPF应用程序,并一直在关注这个。我读过关于MVVM几篇文章,但我在专门找下面的虚线框(所以模型和数据访问)的一切细节。我已经有一个本地数据库安装(SQLite的),我期待它连接到我的应用程序的有效方式。

I'm currently creating a WPF app in C# and have been following this diagram . I've read several articles on MVVM but I 'm specifically looking for details on everything below the dotted box (so the Model and Data access). I already have a local database setup (SQLite) and I'm looking for an efficient way of connecting it to my application.

有没有创造这个特定部分的MVVM任何好的文章或演示?

Are there any good articles or demos of creating this specific part for MVVM?

推荐答案

有很多方法可以解决这个问题,你选择哪一个会被你的应用程序的复杂性和数据模型来确定。

There are many ways to approach this problem and which one you choose will be determined by the complexity of your application and your data model.

本标准的方式来从一个.NET点逼近,这将是对你的SQLite数据库之上建立一个实体框架模型。这将生成你的对象模型,并允许您连接行为,它没有太多的大惊小怪。它也有些来自应用程序的code(的ViewModels)抽象数据库/持久性。有关此方法的详细信息,谷歌搜索实体框架 - 有大量的信息在那里。由于EF 4.0的发布EF有了大幅的提升。

The standard way to approach this from a .NET point of view would be to create an Entity Framework model on top of your SQLite database. This will generate your object model and allow you to attach behaviour to it without too much fuss. It also somewhat abstracts the database/persistence from your application code (ViewModels). For details on this approach, search Google for 'Entity Framework' - there is a ton of information out there. EF has improved dramatically since the release of EF 4.0.

如果你不想去与EF(由于复杂性,开销或者只是推出自己的欲望),那么你将要读上流行的数据源架构模式。先从企业应用架构 Martin Fowler的模式 - 这本书是数据驱动的应用程序体系结构的圣经。如果你不想买这本书,然后通过该模式的描述看,找到一个合适的一个,做一个谷歌搜索 - 有一吨的这个东西在网络上的信息

If you don't want to go with EF (due to complexity, overhead or just the desire to roll your own) then you're going to want to read up on popular data source architectural patterns. Start with Martin Fowler's Patterns of Enterprise Application Architecture - this book is the bible of data-driven application architecture. If you don't want to buy the book then read through the pattern descriptions, find an appropriate one and do a Google search - there is a ton of information about this stuff on the web.

如果你有一个复杂的模型与行为的负载和模式,那么你会想看看领域模型图案模型也可能是数据映射的数据源模式。这是最复杂的方法,但在复杂的灵活性不负有心人,在路上,如果你需要它。

If you have a complex model with loads of behaviour and patterns then you'll want to look at the Domain Model pattern for your model and probably the Data Mapper data source pattern for getting the data out of your DB and into your model. This is the most complicated approach, but the complexity pays off in flexibility down the road, if you need it.

如果您的数据模型是简单的,那么你可能要为使用表数据网关或的行数据网关的数据访问和可能事务脚本服务层的模型和数据库之间的通信。

If your data model is simpler then you may want to use either Table Data Gateway or Row Data Gateway for data access and probably Transaction Script or Service Layer for communication between the model and database.

我的主要轰炸你的链接表示歉意,但现实的情况是在一个架构决定了应用程序做大量的研究很重要,重要的是学习,依靠已知的解决方案的时候。祝你好运。

I apologize for essentially bombarding you with links but the reality is when deciding on an architecture for an application it's important to do lots of research and above all learn and rely upon known solutions. Good luck.

这篇关于MVVM - 型号教程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆