在breeze js中的saveChange之前获取实体状态

时间:2014-03-04 16:20:09

标签: breeze

我正在和mvc一起使用breeze js。当我从特定实体删除一些记录时,当我向控制器发送数据时,因为我需要特定的删除记录及其来自JObject的状态。我有一个像这样的JObject

{
  "entities": [
    {
      "StageDetailID": 7,
      "EventID": 1,
      "StageNUmber": "Stage 1",
      "TypeOfStage": "Primary ",
      "Distance": "100",
      "IsRadioRoadMap": "N",
      "IsRadioCourseApproval": "N",
      "IsRadioTrafficControl": "N",
      "IsRadioPoliceAssistance": "N",
      "IsNeutralSupport": "N",
      "IsKOMQOM": "N",
      "IsSprints": "N",
      "IsFeedStations": "N",
      "IsRoadClosures": "N",
      "IsDetours": "N",
      "IsSpeedReductions": "N",
      "entityAspect": {
        "entityTypeName": "StageDetail:#EventManagement.Domain.Model",
        "defaultResourceName": "StageDetails",
        "entityState": "Deleted",
        "originalValuesMap": {},
        "autoGeneratedKey": {
          "propertyName": "StageDetailID",
          "autoGeneratedKeyType": "Identity"
        }
      }
    }
  ],
  "saveOptions": {}
}

如何从此JObject获取Entity StageDetail和Entity State。感谢

1 个答案:

答案 0 :(得分:1)

在您的控制器中定义保存实体之前如下

public bool BeforeSaveEntity(EntityInfo info) { } 并且在调用“保存更改”方法时会出现问题,您可以从实体中删除记录。

供参考,请浏览以下链接

Breeze before save entites