0

可能重复:
使用 sql CE 的 sqlbulkcopy

我正在尝试将大量数据从 C# 插入 SQL Server CE 数据库。目前我正在使用实体框架、pocos 和 poco 配置类,因为 pocos 的属性名称与数据库中的列名称不匹配。

我已经阅读了很多关于这个主题的文章和博客文章,但没有一篇完全符合我的服务器生成的 id 和外键的问题。

public class Country
{
    public int    Id   { get; set; }
    public string Name { get; set; }
}

public class City
{
    public int    Id      { get; set; }
    public string ZipCode { get; set; }
    public string Name    { get; set; }

    //Foreign Keys
    public int CountryId { get; set; }
}

public class Address
{
    public int Id        { get; set; }
    public string Name   { get; set; }
    public string Number { get; set; }

    //Foreign Keys
    public int CityId    { get; set; }
}

public class Customer
{
    public int Id            { get; set; }
    public string FirstName  { get; set; }
    public string SecondName { get; set; }

    //Foreign Keys
    public int AddressId { get; set; }
}

public class EmailAddress
{
    public int Id       { get; set; }
    public string Email { get; set; }

    //Foreign Keys
    public int CustomerId { get; set; }
}

那是我的 pocos,ID 是服务器生成的。那么在 SQL Server CE 数据库Customers中插入大量数据的最快方法是什么AddressesEmailAddresses

4

0 回答 0