using RepoDb;
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
namespace ExtraFieldTest
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
using (var connection = new DbRepository<SqlConnection>("Server=(local);Database=Test;Integrated Security=True;"))
{
var people = GetPerson(100);
foreach (var person in people)
{
var id = connection.Insert(person);
Console.WriteLine($"Person with id {id} has been inserted.");
}
}
Console.ReadLine();
}
private static IEnumerable<Person> GetPerson(int count)
{
for (var i = 0; i < count; i++)
{
yield return new Person
{
Id = i,
Name = $"Name{i}",
DateOfBirth = DateTime.UtcNow,
Addresses = new[]
{
new Address{Id=1},
new Address{Id=2}
}
};
}
}
private class Person
{
public long Id { get; set; }
public string Name { get; set; }
public DateTime? DateOfBirth { get; set; }
public string OtherValues { get; set; }
public IEnumerable<Address> Addresses { get; set; }
}
public class Address
{
public long Id { get; set; }
}
}
}