breeze and sql server triggers

孤者浪人 提交于 2019-12-11 19:19:55

问题


Breeze don't have a look of what's happened to data at server side when saving these data. Breeze team said you must re-query to have updated data. Actions done synchronously during this saving like sql triggers (expl. After Insert) may be considered because of these operations can transform entities during saving so they take place at client : this will be useful for new keys not generated by Breeze like multi-parts keys. I have difficult to work-around this problem. Help?

UPDATE 1: If this is the principle with Breeze it's probrably a bug.

1) The trigger (at server-side) is part of the entity (table)

2) Frameworks used :

  • server-side framework : .NET Framework 4.5
  • client framework : Breeze 1.3.5
  • view framework : knockout 2.2.1

3) result scenario from saveChanges:

function saveTousRecos() {
    return manager.saveChanges()
             .then(success)
             .fail(fail);
        function success(saveResult) {
            /* do your post-save work here */
            axi = saveResult.entities[0].jobtab();  
        // axi is an identity key generated at server and sent back to client by Breeze
        // result : Breeze value = (195), the same as server-side (195)
            ara = saveResult.entities[0].seqtab();  
        // ara is a property value inserted by sql FOR INSERT trigger, 
        // result : Breeze value = (NULL), server-side has (13)
            logger.log("Saving succeded... ");
        }
        function fail(error) {
            logger.log("Saving failed: " + error.message);
        }
    }

P.S. : all values inserted by SQL triggers are not visible at all unless you re-call entity from server, not from cache; seems like a work-around not the solution I suppose.

UPDATE 2: I think that Breeze considers my return entities as OData like.

1) from my Breeze Api controlleur I use this :

return _contextProvider.Context.clients.Where(uc => uc.refclie == rqnoclie);

2) Breeze said : With OData, any change of the value of a server side computed field will not be available in Breeze after an update. If you need these values refreshed, you must requery...

3) so from now, the solution for me is REQUERY (not good news) to get my computed or triggered results. Hope the future of BeforeSaveEntity interceptors will solve this problem. Or how can I get pure entities for Breeze (not OData but computed or triggered server-side) ? Is there a way to get Out from this trouble?


回答1:


The Breeze EFContextProvider re-queries the entities it saves and sends them back to the client. So it will send values updated by SQL triggers back to the client if those triggers update the entity-being-saved. For example, if you save entity 'A' and a trigger updates a value of entity 'A', the EFContextProvider will re-query 'A' and send those updated values to the client.

Let us know if you can demonstrate that this is not true. I believe that would be a bug.

Breeze doesn't know ... and can't know ... about other entities updated by a SQL trigger. Breeze can't know that entity 'B' was updated by trigger when you saved entity 'A' and has not reason to query 'B' and send it to the client.



来源:https://stackoverflow.com/questions/16880206/breeze-and-sql-server-triggers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!