Breeze NH - 基类上的FK保存错误

时间:2014-01-05 10:17:06

标签: breeze

使用breeze.webapi.nh(1.4.7)我在CredticardPayment对象上有一个简单的TPT / TPH(试过两个)(BasePayment,CreditcardPayment)查询工作得很好,我从基础和派生类中获取数据。

当尝试保存实体并且基类包含FK时,我收到此错误:(如果将FK移动到派生类,则保存起作用并且一切正常)

The given key was not present in the dictionary.
   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
   at Breeze.WebApi.NH.NHRelationshipFixer.GetRelatedEntity(String propName, IType propType, EntityInfo entityInfo, IClassMetadata meta, Boolean canUseSession)
   at Breeze.WebApi.NH.NHRelationshipFixer.FixupRelationship(String propName, IType propType, EntityInfo entityInfo, IClassMetadata meta, Boolean canUseSession)
   at Breeze.WebApi.NH.NHRelationshipFixer.FixupRelationships(EntityInfo entityInfo, IClassMetadata meta, Boolean canUseSession)
   at Breeze.WebApi.NH.NHRelationshipFixer.FixupRelationships(Boolean canUseSession)
   at Breeze.WebApi.NH.NHContext.ProcessSaves(Dictionary`2 saveMap)
   at Breeze.WebApi.NH.NHContext.SaveChangesCore(SaveWorkState saveWorkState)
   at Breeze.WebApi.ContextProvider.OpenAndSave(SaveWorkState saveWorkState)
   at Breeze.WebApi.ContextProvider.SaveChanges(JObject saveBundle, TransactionSettings transactionSettings)
   at YTourWeb.Controllers.BreezeApiController.SaveChanges(JObject saveBundle) in c:\Yayasoft\YTour\YTour\YTourWeb\Controllers\BreezeApiController.cs:line 46

有什么想法吗?

保存包:

{
  "entities": [
    {
      "Id": 5,
      "TotalAmount": 20,
      "CurrencyId": 1,
      "CurrencyRate": 3.5,
      "CreateDate": "2014-01-05T09:54:51Z",
      "PaymentDate": null,
      "OrderId": 316,
      "NumberOfPayments": 0,
      "Token": null,
      "ConfirmationCode": null,
      "HolderFirstName": null,
      "HolderLastName": null,
      "HolderIdNumber": null,
      "LastFourDigits": null,
      "ExpireDate": null,
      "Remarks": null,
      "CardType": "Visa",
      "PaymentType": "Regular",
      "Status": "None",
      "ErrorCode": 0,
      "ChargeDate": null,
      "CVV": null,
      "ClearingService": "NotSet",
      "entityAspect": {
        "entityTypeName": "CreditcardPayment:#BL.Orders",
        "defaultResourceName": "CreditcardPayments",
        "entityState": "Modified",
        "originalValuesMap": {
          "TotalAmount": 10
        },
        "autoGeneratedKey": {
          "propertyName": "Id",
          "autoGeneratedKeyType": "Identity"
        }
      }
    }
  ],
  "saveOptions": {}
}

的元数据:

{
      "shortName": "CreditcardPayment",
      "namespace": "BL.Orders",
      "baseTypeName": "BasePayment:#BL.Orders",
      "autoGeneratedKeyType": "Identity",
      "defaultResourceName": "CreditcardPayments",
      "dataProperties": [
        {
          "nameOnServer": "NumberOfPayments",
          "dataType": "Int32",
          "isNullable": true,
          "validators": [
            {
              "name": "int32"
            }
          ]
        },
        {
          "nameOnServer": "Token",
          "dataType": "String",
          "isNullable": true
        },
        {
          "nameOnServer": "ConfirmationCode",
          "dataType": "String",
          "isNullable": true
        },
        {
          "nameOnServer": "HolderFirstName",
          "dataType": "String",
          "isNullable": true
        },
        {
          "nameOnServer": "HolderLastName",
          "dataType": "String",
          "isNullable": true
        },
        {
          "nameOnServer": "HolderIdNumber",
          "dataType": "String",
          "isNullable": true
        },
        {
          "nameOnServer": "LastFourDigits",
          "dataType": "String",
          "isNullable": true
        },
        {
          "nameOnServer": "ExpireDate",
          "dataType": "DateTime",
          "isNullable": true,
          "validators": [
            {
              "name": "date"
            }
          ]
        },
        {
          "nameOnServer": "Remarks",
          "dataType": "String",
          "isNullable": true
        },
        {
          "nameOnServer": "CardType",
          "dataType": "NHibernate.Type.EnumType`1[[BL.Orders.CreditcardPayment+CreditCardTypes, BL, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], NHibernate",
          "isNullable": true
        },
        {
          "nameOnServer": "PaymentType",
          "dataType": "NHibernate.Type.EnumType`1[[BL.Orders.CreditcardPayment+CreditCardPaymentTypes, BL, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], NHibernate",
          "isNullable": true
        },
        {
          "nameOnServer": "Status",
          "dataType": "NHibernate.Type.EnumType`1[[BL.Orders.CreditcardPayment+CreditCardStatus, BL, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], NHibernate",
          "isNullable": true
        },
        {
          "nameOnServer": "ErrorCode",
          "dataType": "Int32",
          "isNullable": true,
          "validators": [
            {
              "name": "int32"
            }
          ]
        },
        {
          "nameOnServer": "ChargeDate",
          "dataType": "DateTime",
          "isNullable": true,
          "validators": [
            {
              "name": "date"
            }
          ]
        },
        {
          "nameOnServer": "CVV",
          "dataType": "String",
          "isNullable": true
        },
        {
          "nameOnServer": "ClearingService",
          "dataType": "NHibernate.Type.EnumType`1[[BL.Orders.CreditcardPayment+CreditClearingServices, BL, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], NHibernate",
          "isNullable": true
        }
      ],
      "navigationProperties": []
    },
    {
      "shortName": "BasePayment",
      "namespace": "BL.Orders",
      "autoGeneratedKeyType": "Identity",
      "defaultResourceName": "BasePayments",
      "dataProperties": [
        {
          "nameOnServer": "Id",
          "dataType": "Int32",
          "isNullable": false,
          "isPartOfKey": true,
          "validators": [
            {
              "name": "required"
            },
            {
              "name": "int32"
            }
          ]
        },
        {
          "nameOnServer": "TotalAmount",
          "dataType": "Double",
          "isNullable": true
        },
        {
          "nameOnServer": "CurrencyId",
          "dataType": "Int32",
          "isNullable": true,
          "validators": [
            {
              "name": "int32"
            }
          ]
        },
        {
          "nameOnServer": "CurrencyRate",
          "dataType": "Double",
          "isNullable": true
        },
        {
          "nameOnServer": "CreateDate",
          "dataType": "DateTime",
          "isNullable": true,
          "validators": [
            {
              "name": "date"
            }
          ]
        },
        {
          "nameOnServer": "PaymentDate",
          "dataType": "DateTime",
          "isNullable": true,
          "validators": [
            {
              "name": "date"
            }
          ]
        },
        {
          "nameOnServer": "OrderId",
          "dataType": "Int32",
          "isNullable": true,
          "validators": [
            {
              "name": "int32"
            }
          ]
        }
      ],
      "navigationProperties": [
        {
          "nameOnServer": "Currency",
          "entityTypeName": "Currency:#BL",
          "isScalar": true,
          "associationName": "AN_BasePayment_Currency",
          "foreignKeyNamesOnServer": [
            "CurrencyId"
          ]
        },
        {
          "nameOnServer": "Order",
          "entityTypeName": "Order:#BL.Orders",
          "isScalar": true,
          "associationName": "AN_BasePayment_Order",
          "foreignKeyNamesOnServer": [
            "OrderId"
          ]
        }
      ]

1 个答案:

答案 0 :(得分:1)

是的,这是一个错误。对于那个很抱歉。它已在版本1.4.8中修复,应该在明天发布。