使用存储过程将列表对象插入数据库

时间:2016-03-11 07:35:54

标签: c# sql sql-server wpf

我有一个集合NameList,其中包含多个PersonName类对象。

我希望在单个插入操作中使用存储过程将NameList插入到表tbl_namelist中。但在插入之前,它必须删除tbl_namelist中的所有记录。

public class NameList : ObservableCollection<PersonName>
{
    public NameList() : base()
    {
        Add(new PersonName("Willa", "Cather"));
        Add(new PersonName("Isak", "Dinesen"));
        Add(new PersonName("Victor", "Hugo"));
        Add(new PersonName("Jules", "Verne"));
    }
}

public class PersonName
{
      private string firstName;
      private string lastName;

      public PersonName(string first, string last)
      {
          this.firstName = first;
          this.lastName = last;
      }

      public string FirstName
      {
          get { return firstName; }
          set { firstName = value; }
      }

      public string LastName
      {
          get { return lastName; }
          set { lastName = value; }
      }
}

0 个答案:

没有答案
相关问题