Skip to content

[Core] Insert is failing for non-null (non-table) properties (XJNEN) #212

@mikependon

Description

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

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingdeployedFeature or bug is deployed at the current release

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions