示例#1
0
        public void EFCore_Insert_Saves_Guid_As_String()
        {
            var dbFactory = new EfCoreSqliteInMemoryDbFactory("DataSource=ef.db");
            var context   = dbFactory.CreateDbContext <MainContext>(s => _testOutputHelper.WriteLine(s));

            var person = new Person
            {
                Id   = Guid.NewGuid(),
                Name = "John Doe"
            };

            context.Add(person);
            context.SaveChanges();
        }
示例#2
0
        public void BulkCopy_Insert_Saves_Guid_As_String()
        {
            var dbFactory = new EfCoreSqliteInMemoryDbFactory("DataSource=linq2db.db");
            var context   = dbFactory.CreateDbContext <MainContext>(s => _testOutputHelper.WriteLine(s));

            var connection  = context.CreateLinqToDbConnection();
            var peopleTable = connection.GetTable <Person>();

            var person = new Person
            {
                Id   = Guid.NewGuid(),
                Name = "John Doe"
            };

            peopleTable.BulkCopy(new BulkCopyOptions {
                KeepIdentity = true
            }, new List <Person> {
                person
            });
        }