本文整理汇总了C#中System.Db.SaveChanges方法的典型用法代码示例。如果您正苦于以下问题:C# Db.SaveChanges方法的具体用法?C# Db.SaveChanges怎么用?C# Db.SaveChanges使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Db
的用法示例。
在下文中一共展示了Db.SaveChanges方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
Console.WriteLine("Check DB exists...");
if (Database.Exists("MedicalClinicDb"))
{
Console.WriteLine("DB exists. Deleting...");
Database.Delete("MedicalClinicDb");
}
else
{
Console.WriteLine("DB does not exist. Skip deleting.");
}
using (var db = new Db())
{
Console.WriteLine("Creating DB..");
Console.WriteLine("Employees...");
var belova = new Employee
{
FirstName = "Alina",
MiddleName = "Leonidovna",
LastName = "Belova",
LastLoginTime = DateTime.Now,
Login = "ab",
Password = PasswordManager.CreateHash("123")
};
var admin = new Employee
{
FirstName = "-",
MiddleName = "-",
LastName = "-",
LastLoginTime = DateTime.Now,
Login = "admin",
Password = PasswordManager.CreateHash("admin")
};
db.Employees.Add(belova);
db.Employees.Add(admin);
db.SaveChanges();
Console.WriteLine("Clients..");
var cl1 = new Client()
{
FirstName = "Ivan",
MiddleName = "Ivanovich",
LastName = "Ivanov",
BirthDate = new DateTime(2000, 01, 10),
Address = "Mira, 98",
Pasport = "1234567890",
Policy = "001122",
Disease = "Caries"
};
var cl2 = new Client()
{
FirstName = "Petr",
MiddleName = "Petrovich",
LastName = "Petrov",
BirthDate = new DateTime(1960, 05, 20),
Address = "Lenina, 74",
Pasport = "0987654312",
Policy = "213456",
Disease = "Poor eyesight"
};
var cl3 = new Client()
{
FirstName = "Petr",
MiddleName = "Ivanovich",
LastName = "Sidorov",
BirthDate = new DateTime(1971, 10, 11),
Address = "K.Marksa, 2",
Pasport = "4984654312",
Policy = "234567",
Disease = "/---/"
};
db.Clients.Add(cl1);
db.Clients.Add(cl2);
db.Clients.Add(cl3);
db.SaveChanges();
Console.WriteLine("Doctors...");
var doc1 = new Doctor()
{
Speciality = "Dentist",
FirstName = "Svetlana",
MiddleName = "Victorovna",
LastName = "Konova",
Cabinet = 15,
WorkHours = "10.00 - 15.00",
Cost = 750,
Talons = new List<Talon>
{
new Talon(){DateStart = new DateTime(2015, 07, 22, 10, 00, 00)},
new Talon(){DateStart = new DateTime(2015, 07, 22, 10, 30, 00)},
new Talon(){DateStart = new DateTime(2015, 07, 22, 14, 30, 00)},
new Talon(){DateStart = new DateTime(2015, 07, 23, 10, 00, 00)},
new Talon(){DateStart = new DateTime(2015, 07, 24, 10, 30, 00)},
new Talon(){DateStart = new DateTime(2015, 07, 25, 14, 30, 00)}
}
};
var doc2 = new Doctor()
//.........这里部分代码省略.........