Hi I am new to BreezeJs

I have a post method on Controller

// POST api/company/post
        [Authorize(Roles = "Admin")]
        [AcceptVerbs("POST")]
        [HttpPost]
        public object **SaveChanges**(JObject companyRequest)
        {
            return companyService.SaveEntity(companyRequest);
        }

And i have call this method in breezejs

manager.**saveChanges**().then(saveSucceeded).fail(saveFailed);

This saveChanges() is same name as controller method name. So it's working now!

But if i change the controller Method name SaveChanges() to SaveChangesCompany() and change to the breeze side to manager.SaveChangesCompany()

Code look like

// POST api/company/post
            [Authorize(Roles = "Admin")]
            [AcceptVerbs("POST")]
            [HttpPost]
            public object **SaveChangesCompany(JObject companyRequest)**
            {
                return companyService.SaveEntity(companyRequest);
            }

and the breeze side

**manager.saveChangesCompany(**).then(saveSucceeded).fail(saveFailed);

Then it's does not work. Why the manager.saveChanges() does work and manager.saveChangesCompany() does not work?

How can i do this scenario with breezejs?

Please please help me guy's!! Thanks !

有帮助吗?

解决方案

There is no physical connection between the names of the saveChanges method on the EntityManager and the SaveChanges method on the server. Changing one does not change the other.

If you want to use a different method name on the controller, you need to specify it in the SaveOptions that is passed to the saveChanges method on the entity manager:

var so = new SaveOptions({ resourceName: "SaveChangesCompany" });
manager.saveChanges(null, so );

See the Breeze Documentation for more info.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top