static void PopulateCarData(List <Vehicle> vehicles) { var vauxhall = new Manufacturer { Name = "Vauxhall" }; var astra = vauxhall.LaunchNewModel("Astra", 14000M); var corsa = vauxhall.LaunchNewModel("Corsa", 11000M); vehicles.Add(vauxhall.Create <DieselCar>(astra, "123ABC", 2006, Condition.Good)); vehicles.Add(vauxhall.Create <PetrolCar>(corsa, "456DEF", 2008, Condition.Good).WithEngineSize(1200)); var mini = new Manufacturer { Name = "Mini" }; var cooper = mini.LaunchNewModel("Cooper", 9000M); vehicles.Add(mini.Create <PetrolCar>(cooper, "789XYZ", 1984, Condition.Good)); var vw = new Manufacturer { Name = "Volkswagen" }; var beetle = mini.LaunchNewModel("Beetle", 6500M); vehicles.Add(vw.Create <PetrolCar>(beetle, "AB4567", 1957, Condition.Good).WithEngineSize(800)); }
static void Main(string[] args) { try { Manufacturer m = new Manufacturer(); m.Name = "Roland"; m.Create(); Product p = new Product(); p.Manufacturer = m; p.Name = "Juno G"; p.Create(); //create a different date updated System.Threading.Thread.Sleep(2000); p.Name = "Juno D 61 Key Pro Keyboard"; p.Update(); Product[] products = Product.FindAll(); foreach (Product product in products) { Console.WriteLine("{0} by {1} was last modified on {2}", product.Name, product.Manufacturer.Name, product.ModifiedDate); } } catch (Exception ex) { Console.WriteLine(ex.GetBaseException().Message); } }
public void CreateAndSaveManufacturer() { using (var context = new YoumotoDbContext(Effort.DbConnectionFactory.CreateTransient())) { Manufacturer manufacturer = Manufacturer.Create(ManufacturerTests.manufacturerName); context.Manufacturers.Add(manufacturer); context.SaveChanges(); Assert.AreEqual(ManufacturerTests.manufacturerName, manufacturer.Name); } }
public void CreateModelWithReferencedModel_ReferencedModelHasPk() { Fakes.DbConnection.CreatedCommands.Clear(); Fakes.DbConnection.ClearCustomExecuteResults(); Fakes.DbConnection.AddCustomExecuteScalarResult(Product.Sql.LastPrimaryKey, 1); var product = Product.Create(p => { p.Manufacturer = Manufacturer.Create(); p.Name = "My imaginary product"; }); Assert.AreEqual(1, product.Manufacturer.Id); }
public void CreateAndSaveSeries() { using (var context = new YoumotoDbContext(Effort.DbConnectionFactory.CreateTransient())) { Manufacturer manufacturer = Manufacturer.Create(SeriesTests.manufacturerName); Series series = Series.Create(manufacturer, SeriesTests.seriesName); context.Manufacturers.Add(manufacturer); context.Series.Add(series); context.SaveChanges(); Assert.AreEqual(SeriesTests.seriesName, series.Name); } }
public void CreateAndSaveVehicleWithAssociationToManufacturer() { using (var context = new YoumotoDbContext(Effort.DbConnectionFactory.CreateTransient())) { Manufacturer manufacturer = Manufacturer.Create(VehicleTests.manufacturerName); context.Manufacturers.Add(manufacturer); Vehicle vehicle = Vehicle.Create(VehicleTests.vehicleName); context.Vehicles.Add(vehicle); ManufacturerVehicle manufacturerVehicle = ManufacturerVehicle.Create(manufacturer, vehicle); context.ManufacturerVehicles.Add(manufacturerVehicle); context.SaveChanges(); Assert.AreEqual(1, vehicle.ManufacturerVehicles.Count()); Assert.AreEqual(manufacturer, vehicle.ManufacturerVehicles.First().Manufacturer); } }