Prism DAL 何时/何处访问

发布于 2024-10-31 11:41:31 字数 267 浏览 2 评论 0原文

一般问题,人们何时在 Prism 应用程序中访问他们的 DAL?

也就是说,如果模块需要数据,您是否会在模块加载时查询 DAL(我目前一直在使用 OnImportsSatisfiedINavigationAware.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 OnImportsSatisfiedandINavigationAware.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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

如痴如狂 2024-11-07 11:41:31

在我当前的项目中,我们以这种方式构建应用程序,即所有视图模型在其自身初始化后异步从一个 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文