Prism DAL 何时/何处访问
一般问题,人们何时在 Prism 应用程序中访问他们的 DAL?
也就是说,如果模块需要数据,您是否会在模块加载时查询 DAL(我目前一直在使用 OnImportsSatisfied和
INavigationAware.OnNavigateTo`(从上一个视图传递参数)。
显然,我不希望不同的模块紧密耦合,但对于一个模块中有多个视图的示例,从 UI 响应能力的角度来看,预先检索数据并将其传递到新视图会更好吗
?他们对此有什么想法可以分享吗?
General question, when do people access their DAL in a prism application?
That is to say, if a module requires data do you query the DAL on the module load (I've currently been using OnImportsSatisfiedand
INavigationAware.OnNavigatedTo` (passing in a parameter from the previous view).
Obviously I wouldn't want different modules to be tightly coupled but for an example where I have multiple views in a module would it be better from the UI responsiveness point of view to retrieve the data up front and pass it into the new view?
Anyone got any thoughts on this that they could share? Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在我当前的项目中,我们以这种方式构建应用程序,即所有视图模型在其自身初始化后异步从一个 wcf 服务代理查询其数据。代理本身从服务器查询它们并在内部缓存。因此,您必须考虑缓存策略。
但这会导致以下行为: 用户界面是由区域经理构建的。一开始它是空的。数据从服务器到达一小段时间后,视图模型获取其模型,从中读取数据,视图的数据上下文(即视图模型)被填充,因此视图被填充。
您的问题的答案是:视图模型在以异步方式创建后查询 DAL(在我的例子中是 wcf 服务代理)。
In my current project we build the application this way that all view models asynchronouls query their data from one wcf service proxy after their own initialization. The proxy itself queries them from the server and caches it internally. Thus you have to think about a caching strategy.
But this leads to the following behaviour: The user interface is build up by the region manager. At the beginning it is empty. After a short time the data arrives from the server, the view models get their model, read the data from it, the data context of the view (which is the view model) is filled up and so the view is populated.
The answer to your question is: The view model queries the DAL (in my case the wcf service proxy) after it's creation in asynchronous way.