本文整理汇总了C#中ConcurrencyModel.F1Context.Add方法的典型用法代码示例。如果您正苦于以下问题:C# F1Context.Add方法的具体用法?C# F1Context.Add怎么用?C# F1Context.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConcurrencyModel.F1Context
的用法示例。
在下文中一共展示了F1Context.Add方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SeedAsync
public static async Task SeedAsync(F1Context context)
{
if (await context.Database.EnsureCreatedAsync())
{
foreach (var engineSupplier in new List<EngineSupplier>
{
new EngineSupplier
{
Name = "Mercedes"
},
new EngineSupplier
{
Name = "Renault"
},
new EngineSupplier
{
Name = "Ferrari"
},
new EngineSupplier
{
Name = "Cosworth"
},
})
{
context.Add(engineSupplier);
}
// TODO: Remove once local queries work
await context.SaveChangesAsync();
var engineSuppliers = context.EngineSuppliers;
var mercedesEngine = new Engine
{
Name = "FO 108X",
StorageLocation = new Location
{
Latitude = 47.64491,
Longitude = -122.128101
},
EngineSupplier = engineSuppliers.Single(s => s.Name == "Mercedes")
};
var renaultEngine = new Engine
{
Name = "RS27-2010",
StorageLocation = new Location
{
Latitude = 47.644199,
Longitude = -122.127049
},
EngineSupplier = engineSuppliers.Single(s => s.Name == "Renault")
};
var ferrariEngine = new Engine
{
Name = "056",
StorageLocation = new Location
{
Latitude = 47.64256,
Longitude = -122.130609
},
EngineSupplier = engineSuppliers.Single(s => s.Name == "Ferrari")
};
var cosworthEngine = new Engine
{
Name = "CA2010",
StorageLocation = new Location
{
Latitude = 47.644851,
Longitude = -122.129781
},
EngineSupplier = engineSuppliers.Single(s => s.Name == "Cosworth")
};
foreach (var engine in new List<Engine>
{
mercedesEngine,
renaultEngine,
ferrariEngine,
cosworthEngine
})
{
context.Engines.Add(engine);
}
foreach (var team in new List<Team>
{
new Team
{
Id = Team.McLaren,
Name = "Vodafone McLaren Mercedes",
Constructor = "McLaren",
Chassis = new Chassis
{
Name = "MP4-25"
},
Engine = mercedesEngine,
Tire = "Bridgestone",
Principal = "Martin Whitmarsh",
ConstructorsChampionships = 8,
DriversChampionships = 12,
Races = 678,
//.........这里部分代码省略.........