1

我正在使用 facebook RTU 并获取有关我的应用程序用户付款的 json 更新。为了获得更好的客户服务,我想保存 facebook 发送给我的所有 json 字符串,但要以有序的方式。

例如,我得到这个 json:

{
  "id": "3603105474213890",
  "user": {
    "name": "Daniel Schultz",
    "id": "221159"
  },
  "application": {
    "name": "Friend Smash",
    "namespace": "friendsmashsample",
    "id": "241431489326925"
  },
  "actions": [
    {
      "type": "charge",
      "status": "completed",
      "currency": "USD",
      "amount": "0.99",
      "time_created": "2013-03-22T21:18:54+0000",
      "time_updated": "2013-03-22T21:18:55+0000"
    }
  ],
  "refundable_amount": {
    "currency": "USD",
    "amount": "0.99"
  },
  "items": [
    {
      "type": "IN_APP_PURCHASE",
      "product": "http://www.friendsmash.com/og/friend_smash_bomb.html",
      "quantity": 1
    }
  ],
  "country": "US",
  "created_time": "2013-03-22T21:18:54+0000",
  "payout_foreign_exchange_rate": 1,
  "disputes": [
    {
      "user_comment": "I didn't receive my item! I want a refund, please!",
      "time_created": "2013-03-24T18:21:02+0000",
      "user_email": "email\u0040domain.com"
    }
  ]
}

而且我想将它保存在数据库中,但不是作为字符串,作为这种样式的对象,并且还可以选择通过我的数据库中的字段值进行查询。

        public class PaymentDetailsDto
        {
            public string id { get; set; }
            public PaidUserDto user { get; set; }
            public PaidApplicationDto application { get; set; }
            public List<PaymentActionDto> actions { get; set; }
            public RefundableAmountDto refundable_amount { get; set; }
            public List<PaymentItemDto> items { get; set; }
            public string country { get; set; }
            public string created_time { get; set; }
            public int test { get; set; }
            public int payout_foreign_exchange_rate { get; set; }
            public List<DisputeDto> disputes { get; set; }
        }

你如何建议在数据库中表示这个实体?

如您所见List,我的 Root 对象中有三个对象,这使得决定如何保存它变得有点复杂。

  • 我们不会使用 EntityFramework 或 NHibernate。
4

0 回答 0