更新db中的复杂实体

时间:2013-10-20 15:22:01

标签: c# .net sql sql-server database

我正在使用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"
    }
  ]
}

我想将它保存在db中,但不是作为字符串保存,作为此样式的对象,还可以选择按我的db中的字段值进行查询。

        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; }
        }

您如何建议在db中表示此实体?

如你所见,我的Root对象中有三个List个对象,这就是决定如何保存它的原因。

  • 我们不会使用EntityFramework或NHibernate。

0 个答案:

没有答案