如果模型位于单独的项目中,如何在viewmodel和模型之间进行通信? [英] How to communicate between the viewmodel and the model if the model is in a separate project?

查看:66
本文介绍了如果模型位于单独的项目中,如何在viewmodel和模型之间进行通信?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我是WPF和Entity Framework的新手。我打算在WPF客户端应用程序和实体框架中使用MVVM模型。出于安全原因,我将模型(实体框架)保存在一个单独的项目中,即我的客户端应用程序将只具有视图和视图模型。在这种情况下,这是在模型和视图模型之间进行通信的最佳方式吗?



提前感谢...

解决方案

一个单独的项目只是创建一个单独的程序集,应由其他程序集引用。 与单片解决方案相比几乎没有差别。您只需要考虑访问修饰符:如果某个类型和它的成员要被不同的程序集访问,它应该具有<对于某些基类的成员,code> public 访问修饰符或 protected 。在程序集内部访问的类型和成员应该是 internal



我希望你知道如何引用程序集。我强烈建议将所有引用的程序集保存在一个解决方案中并使用项目引用,使用添加引用窗口中的项目选项卡(而不是浏览选项卡)。



我所有其他方面,你使用与单片解决方案完全相同的方式使用另一个组件的声明,



-SA

Hi all,

I am new to WPF and Entity Framework. I am planning to use MVVM pattern in a WPF client application and Entity Framework for model. For security reasons, I am keeping the model(Entity Framework) in a separate project i.e my client application will have only view and viewmodel. In this case which is the best way to communicate between model and viewmodel?

Thanks in advance...

解决方案

A separate project simply makes a separate assembly which should be referenced by other assemblies. It makes almost no differences compared to the monolithic solution. You only need to take into account access modifiers: if some type and it''s member are to be accessed by a different assemblies, it should have public access modifier, or protected, for members of some base classes. Types and members to be accessed inside assembly only should be internal.

I hope you know how to reference assemblies. I would highly recommend to keep all referenced assemblies in one solution and use referencing by projects, using the "Project" tab in the "Add Reference" window (not "Browse" tab).

I all other respects, you use the declarations of another assembly in exact same way as in a monolithic solution,

—SA


这篇关于如果模型位于单独的项目中,如何在viewmodel和模型之间进行通信?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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