public void S_DataObject_Should_CRUD_An_Item_With_Shared_Transactional_Data_Context()
        {
            using (var context = new DataContext())
            {
                var dodge = new Manufacturer { Name = "Dodge", BuildYear = 1900 };
                manufacturerDataObject.Insert(dodge, context);

                dodge.BuildYear = 1915;
                manufacturerDataObject.Update(dodge, context);
                var updatedDodge = context.First<Manufacturer>("SELECT TOP 1 * FROM Le_Manufacturer WHERE Name = 'Dodge'");

                var m4s = new Car { Name = "M4S", ModelYear = 1984, Category = CarCategory.Prototype, ManufacturerId = dodge.TheId };
                carDataObject.Insert(m4s, context);
                var createdM4s = carDataObject.Select.With(context).First("WHERE Name = 'M4S'");

                carDataObject.Delete(m4s, context);
                var deletedM4s = carDataObject.Select.With(context).First("WHERE Name = 'M4S'");

                updatedDodge.BuildYear.Should().Be(1915);
                createdM4s.Should().NotBeNull();
                deletedM4s.Should().BeNull();

                context.Commit();
            }

            var createdDodgeOutsiteContext = manufacturerDataObject.Select.First("WHERE Name = 'Dodge'");
            createdDodgeOutsiteContext.Should().NotBeNull();
        }
        public void C_DataContext_Non_Transitional_Should_Execute_A_Insert_SQL_Command_With_Object_Parameters_And_Read_Created_Data_In_Same_And_Count_Data()
        {
            using (var context = new DataContext(Transaction.No))
            {
                var insertParameters = new Manufacturer { Name = "General Motors", BuildYear = 1908 };
                context.Execute("INSERT INTO Le_Manufacturer VALUES (@Name, @BuildYear)", insertParameters);
                var manufacturer = context.First<Manufacturer>("SELECT * FROM Le_Manufacturer WHERE BuildYear = 1908");
                var manufacturerCount = context.GetValue<int>("SELECT COUNT(TheId) FROM Le_Manufacturer");

                manufacturer.TheId.Should().BeGreaterThan(0);
                manufacturer.Name.Should().Be("General Motors");
                manufacturer.BuildYear.Should().Be(1908);
                manufacturerCount.Should().Be(3);
            }
        }
        public void O_DataObject_Should_Create_Item_From_Database_With_Custom_Table_Name_And_Primary_Key()
        {
            var manufacturer = new Manufacturer { Name = "Lamborghini", BuildYear = 1963 };
            manufacturerDataObject.Insert(manufacturer);
            var queryParams = new { Name = "Lamborghini" };
            var createdManufacturer = manufacturerDataObject.Select.First("WHERE Name = @Name", queryParams);

            manufacturer.TheId.Should().BeGreaterThan(0);
            createdManufacturer.Name.Should().Be("Lamborghini");
            createdManufacturer.BuildYear.Should().Be(1963);
        }