如何将多个类(关联)映射到实体框架7中的单个表

时间:2016-05-10 18:42:22

标签: entity-framework

我想将下面的实体存储到一个表中。我收到来自REST apis的响应,它是分层JSON,但我需要将JSON结构和Store作为平面结构存入sql server数据库。我正在使用新的.net框架和EF 7.

CampaignID  (id)
CampaignTitle   (settings.title)
CampaignType    (type)
Status  (status)
EmailsSent  (emails_sent)
SendTime    (send_time)
RecipientsListId    (recipients.list_id)
RptSmryOpens    report_summary.opens
RptSmryUniqOpens    report_summary.unique_opens
RptSmryOpenRate report_summary.open_rate
RptSmryClicks   report_summary.clicks
RptSmrySubsClicks   report_summary.subscriber_clicks
RptSmryClickRate    report_summary.click_rate


public class Campaign
{
    [JsonProperty("id")]
    public string Id { get; set; }
    [JsonProperty(@"settings")]
    public Settings Settings { get; set; }
    [JsonProperty("type")]
    public string Type { get; set; }
    [JsonProperty("report_summary")]
    public ReportSummary ReportSummary { get; set; }
}

public class Settings
{
    [JsonProperty("title")]
    public string Title { get; set; }
}

public class ReportSummary
{

    [JsonProperty("opens")]
    public int Opens { get; set; }
    [JsonProperty("unique_opens")]
    public int UniqueOpens { get; set; }
    [JsonProperty("open_rate")]
    public double OpenRate { get; set; }
    [JsonProperty("clicks")]
    public int Clicks { get; set; }
    [JsonProperty("subscriber_clicks")]
    public int SubscriberClicks { get; set; }
    [JsonProperty("click_rate")]
    public double ClickRate { get; set; }
}

0 个答案:

没有答案