public void CreateTwice()
        {
            var db = new TestDb();

            var product = TableMapping.Build <ProductPoco> ()
                          .TableName("Product")
                          .PrimaryKey(x => x.Id, autoIncrement: true)
                          .ToMapping();

            var order = TableMapping.Build <OrderPoco>()
                        .TableName("Order")
                        .PrimaryKey(x => x.Id, autoIncrement: true)
                        .ToMapping();

            var orderLine = TableMapping.Build <OrderLinePoco> ()
                            .TableName("OrderLine")
                            .PrimaryKey(x => x.Id, autoIncrement: true)
                            .Index("IX_OrderProduct", x => x.OrderId, x => x.ProductId)
                            .ToMapping();

            var orderHistory = TableMapping.Build <OrderHistoryPoco>()
                               .TableName("OrderHistory")
                               .PrimaryKey(x => x.Id, autoIncrement: true)
                               .ToMapping();

            db.CreateTable(product);
            db.CreateTable(order);
            db.CreateTable(orderLine);
            db.CreateTable(orderHistory);

            VerifyCreations(db);
        }
        public void WithoutRowId()
        {
            using (var conn = new TestDb()) {
                var master = TableMapping.Build <SqliteMaster> ()
                             .TableName("sqlite_master")
                             .ColumnName(x => x.Type, "type")
                             .ColumnName(x => x.Name, "name")
                             .ColumnName(x => x.TableName, "tbl_name")
                             .ColumnName(x => x.RootPage, "rootpage")
                             .ColumnName(x => x.Sql, "sql")
                             .ToMapping();

                var wantsNoRowId = TableMapping.Build <WantsNoRowId> ()
                                   .PrimaryKey(x => x.Id)
                                   .WithoutRowId()
                                   .ToMapping();

                var orderLine = TableMapping.Build <OrderLinePoco> ()
                                .TableName("OrderLine")
                                .PrimaryKey(x => x.Id, autoIncrement: true)
                                .Index("IX_OrderProduct", x => x.OrderId, x => x.ProductId)
                                .ToMapping();

                conn.CreateTable(orderLine);
                var info = conn.Table <SqliteMaster> (master).Where(m => m.TableName == "OrderLine").First();
                Assert.That(!info.Sql.Contains("without rowid"));

                conn.CreateTable(wantsNoRowId);
                info = conn.Table <SqliteMaster> (master).Where(m => m.TableName == "WantsNoRowId").First();
                Assert.That(info.Sql.Contains("without rowid"));
            }
        }
        public void CreateTypeWithNoProps()
        {
            var db = new TestDb();

            var mapping = TableMapping.Build <NoPropObject> ().ToMapping();

            db.CreateTable(mapping);
        }
        public void Issue115_MissingPrimaryKey()
        {
            using (var conn = new TestDb()) {
                var mapping = TableMapping.Build <Issue115_MyObject> ()
                              .PrimaryKey(x => x.UniqueId)
                              .ToMapping();
                conn.CreateTable(mapping);
                conn.InsertAll(from i in Enumerable.Range(0, 10)
                               select new Issue115_MyObject {
                    UniqueId   = i.ToString(),
                    OtherValue = (byte)(i * 10),
                });

                var query = conn.Table <Issue115_MyObject> (mapping);
                foreach (var itm in query)
                {
                    itm.OtherValue++;
                    Assert.AreEqual(1, conn.Update(itm, typeof(Issue115_MyObject)));
                }
            }
        }
            public DbSchema()
            {
                Products = TableMapping.Build <ProductPoco> ()
                           .TableName("Product")
                           .PrimaryKey(x => x.Id, autoIncrement: true)
                           .ToMapping();

                Orders = TableMapping.Build <OrderPoco> ()
                         .TableName("Order")
                         .PrimaryKey(x => x.Id, autoIncrement: true)
                         .ToMapping();

                OrderLines = TableMapping.Build <OrderLinePoco> ()
                             .TableName("OrderLine")
                             .PrimaryKey(x => x.Id, autoIncrement: true)
                             .Index("IX_OrderProduct", x => x.OrderId, x => x.ProductId)
                             .ToMapping();

                OrderHistory = TableMapping.Build <OrderHistoryPoco> ()
                               .TableName("OrderHistory")
                               .PrimaryKey(x => x.Id, autoIncrement: true)
                               .ToMapping();
            }