Esempio n. 1
0
        public void RowWithReservedSqlKeywordAsColumnNameShouldBeInserted()
        {
            using (var db = new MiscellaneousContext())
            {
                var e = new ReservedSqlKeyword
                {
                    Identity = 10
                };
                db.BulkInsertAll(new[] { e });

                Assert.AreEqual(10, e.Identity);
            }
        }
Esempio n. 2
0
        public void RowWithCompositePrimaryKeyShouldBeInserted()
        {
            using (var db = new MiscellaneousContext())
            {
                var x = new Coordinate
                {
                    Value = 1
                };
                var y = new Coordinate
                {
                    Value = 2
                };
                var p = new Point
                {
                    XCoordinate = x,
                    YCoordinate = y,
                    Value       = 100
                };
                db.BulkInsertAll(new[] { p }, null, true);

                Assert.AreEqual(100, p.Value);
            }
        }
        public void FillingUpTableWithPrimaryKeyColumnOnlyShouldBePossible()
        {
            using (var db = new MiscellaneousContext())
            {
                var entities = new List <EmptyTable>();
                for (int i = 0; i < 1000; i++)
                {
                    entities.Add(new EmptyTable());
                }

                var request = new BulkInsertRequest <EmptyTable>
                {
                    AllowNotNullSelfReferences = AllowNotNullSelfReferences.No,
                    EnableRecursiveInsert      = EnableRecursiveInsert.NoButRetrieveGeneratedPrimaryKeys,
                    Entities = entities
                };

                db.BulkInsertAll(request);
                for (int i = 0; i < 1000; i++)
                {
                    Console.WriteLine(entities[i].Id);
                }
            }
        }