gpt4 book ai didi

javascript - Breeze createEntity 类型无法识别

转载 作者:行者123 更新时间:2023-11-28 09:16:30 24 4
gpt4 key购买 nike

我正在尝试使用 BreezeJS 调用服务器,但无法让它工作。它说 tblMovie 无法识别。我找不到问题:S

当我想添加新电影时,它会这样说。

show.js

self.viewAddMovieModal = function () {
self.app.showModal(new self.addmovie()).then(function (result) {
if (result != undefined) {
var movie = dataservice.createMovie({
Title: result[0].title,
Director: result[0].director
});
if (movie.entityAspect.validateEntity()) {
self.movies.push(new movie(result[0].title, result[0].director));
dataservice.saveChanges();
} else {
alert("Error");
}
}
});
};

我的 dataservice.js 层

/// <reference path="../../Scripts/breeze.debug.js"/>

define(["require"], function (require) {

var Dataservice = (function () {
function Dataservice(service) {
this.serviceName = '';
this._isSaving = false;
this.serviceName = service;
this.Manager = new breeze.EntityManager(this.serviceName);
this.EntityQuery = new breeze.EntityQuery();
}
Dataservice.prototype.getAllMovies = function () {
this.EntityQuery = breeze.EntityQuery.from("AllMovies");
return this.Manager.executeQuery(this.EntityQuery);
};

Dataservice.prototype.createMovie = function (initialValues) {
return this.Manager.createEntity('tblMovies', initialValues); //THis is where it goes wrong :(
};

Dataservice.prototype.saveChanges = function (suppressLogIfNothingToSave) {
if (this.Manager.hasChanges()) {
if (this._isSaving) {
setTimeout(this.saveChanges, 50);
return;
}
this.Manager.saveChanges().then(this.saveSucceeded).fail(this.saveFailed).fin(this.saveFinished);
} else if (!suppressLogIfNothingToSave) {
}
};
Dataservice.prototype.saveSucceeded = function (saveResult) {
this._isSaving = false;
};
Dataservice.prototype.saveFailed = function (error) {
};
Dataservice.prototype.saveFinished = function () {
this._isSaving = false;
};
return Dataservice;
})();
return Dataservice;
})

我有一个 tblMovie 模型

using System;
using System.ComponentModel.DataAnnotations;


namespace DurandalMovieApp.Models
{
public class tblMovie
{
[Key]
public int MovieID { get; set; }
public string Title { get; set; }
public string Director { get; set; }
}
}

希望有人能帮忙!

最佳答案

我认为问题在于您的实体是:tblMovie,而不是 tblMovies。

尝试替换:

return this.Manager.createEntity('tblMovies', initialValues);

与:

return this.Manager.createEntity('tblMovie', initialValues);

关于javascript - Breeze createEntity 类型无法识别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15574770/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com