如何使用Breeze使用View和存储过程保存数据 [英] How to save data with a View and stored procedure using Breeze

查看:91
本文介绍了如何使用Breeze使用View和存储过程保存数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在通过WebAPI在服务器上使用BreezeJs。我继承了一个第三方应用程序,该应用程序从各种查找表和自定义字段表中提取数据。为简化起见,我创建了一个SQL视图,该视图将所有数据收集在一起并为其提供了良好的列名。该实体称为游戏,我的移动应用程序在客户端上使用Breeze来获取游戏。一切正常。

I am using BreezeJs on the server via WebAPI. I have inherited a 3rd party app which pulls data from a variety of lookup tables and custom field tables. To simplify things, I created a SQL View which pulls all the data together and gives them good column names. This Entity is called a "Game" and my mobile app uses Breeze on the client to get games. This all works fine.

我不确定如何进行储蓄。

I am unsure how to proceed when it comes to Saving.

我需要使用标准的Breeze保存语法,但是在服务器上,我认为需要拦截Save方法并运行自定义存储过程以将每一列保存到正确的位置

I need to use the standard Breeze save syntax but on the server I assume something needs to intercept the Save method and run a custom stored procedure to save each column to the correct table.

所以我的问题是:我在使用视图(而不是表)和Breeze保存实体方面是否正确?

So my question is: Am I on the right track on how to save entities with Views (not tables) and Breeze?

推荐答案

您要尝试的内容很合理。在这里查看有关保存拦截的讨论: http://www.getbreezenow.com/documentation/contextprovider

What you are attempting makes perfect sense. Take a look at the discussion of save interception here: http://www.getbreezenow.com/documentation/contextprovider.

但是,考虑到微风可以直接支持对象图。使用结构更接近表结构的实体并使用微风导航属性访问相关数据可能更有意义。您仍然可以通过返回实体集合(适用于查找表)的匿名投影查询来批量加载数据,也可以使用EntityQuery.extend方法单遍查找相关数据。

However, given that breeze can support your object graph directly. It might more sense to work with entities that are structured to be closer to your table structure and use breeze navigation properties to access related data. You can still load your data in bulk via either anonymous projection queries that returns collections of entities ( good for lookup tables) or use the EntityQuery.extend method to look related data in a single pass.

很明显,选择哪种方式取决于您需要编写的额外代码的复杂性和数量。但是,如果您只有几个意见,那么我可以采用您建议的方法。随着视图数量的增加,我建议的替代方法可能更有意义。

Obviously, the decision about which way to go is dependent on the complexity and amount of additional code you need to write. But if you only have a few views then I might go with your suggested approach. As the number of views grows, the alternative approach I've suggested may make more sense.

这篇关于如何使用Breeze使用View和存储过程保存数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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