add mapping for property classes
This commit is contained in:
parent
509df68f00
commit
5d7b10148e
|
@ -23,6 +23,8 @@ namespace Server.DB
|
|||
{
|
||||
using (Context ctx = new Context())
|
||||
{
|
||||
var country = ctx.Countries.FirstOrDefault(c => c.CountryID == city.Country.CountryID);
|
||||
ctx.Countries.Attach(country);
|
||||
ctx.Cities.Add(city);
|
||||
ctx.SaveChanges();
|
||||
}
|
||||
|
|
|
@ -25,6 +25,15 @@ namespace Server.DB
|
|||
{
|
||||
using (Context ctx = new Context())
|
||||
{
|
||||
var city = ctx.Cities.FirstOrDefault(c => c.CityID == doctor.City.CityID);
|
||||
var country = ctx.Countries.FirstOrDefault(c => c.CountryID == doctor.City.Country.CountryID);
|
||||
var salutation = ctx.Salutations.FirstOrDefault(s => s.SalutationID == doctor.Salutation.SalutationID);
|
||||
var gender = ctx.Genders.FirstOrDefault(g => g.GenderID == doctor.Gender.GenderID);
|
||||
|
||||
ctx.Cities.Attach(city);
|
||||
ctx.Countries.Attach(country);
|
||||
ctx.Genders.Attach(gender);
|
||||
ctx.Salutations.Attach(salutation);
|
||||
ctx.Doctors.Add(doctor);
|
||||
ctx.SaveChanges();
|
||||
}
|
||||
|
|
|
@ -25,6 +25,28 @@ namespace Server.DB
|
|||
{
|
||||
using (Context ctx = new Context())
|
||||
{
|
||||
var patient = ctx.Persons.FirstOrDefault(p => p.PersonID == exam.Patient.PersonID);
|
||||
var pCity = ctx.Cities.FirstOrDefault(c => c.CityID == patient.City.CityID);
|
||||
var pCountry = ctx.Countries.FirstOrDefault(c => c.CountryID == pCity.Country.CountryID);
|
||||
var pGender = ctx.Genders.FirstOrDefault(g => g.GenderID == patient.Gender.GenderID);
|
||||
var pSalutation = ctx.Salutations.FirstOrDefault(s => s.SalutationID == patient.Salutation.SalutationID);
|
||||
var doctor = ctx.Doctors.FirstOrDefault(d => d.PersonID == exam.Doctor.PersonID);
|
||||
var dCity = ctx.Cities.FirstOrDefault(c => c.CityID == doctor.City.CityID);
|
||||
var dCountry = ctx.Countries.FirstOrDefault(c => c.CountryID == dCity.Country.CountryID);
|
||||
var dGender = ctx.Genders.FirstOrDefault(g => g.GenderID == doctor.Gender.GenderID);
|
||||
var dSalutation = ctx.Salutations.FirstOrDefault(s => s.SalutationID == doctor.Salutation.SalutationID);
|
||||
var strain = ctx.Strains.FirstOrDefault(s => s.StrainID == exam.Strain.StrainID);
|
||||
|
||||
ctx.Persons.Attach(patient);
|
||||
ctx.Doctors.Attach(doctor);
|
||||
ctx.Cities.Attach(pCity);
|
||||
ctx.Cities.Attach(dCity);
|
||||
ctx.Countries.Attach(dCountry);
|
||||
ctx.Countries.Attach(pCountry);
|
||||
ctx.Genders.Attach(dGender);
|
||||
ctx.Genders.Attach(pGender);
|
||||
ctx.Salutations.Attach(dSalutation);
|
||||
ctx.Salutations.Attach(pSalutation);
|
||||
ctx.Exams.Add(exam);
|
||||
ctx.SaveChanges();
|
||||
}
|
||||
|
|
|
@ -24,6 +24,11 @@ namespace Server.DB
|
|||
{
|
||||
using (Context ctx = new Context())
|
||||
{
|
||||
var city = ctx.Cities.FirstOrDefault(c => c.CityID == foodplace.City.CityID);
|
||||
var country = ctx.Countries.FirstOrDefault(c => c.CountryID == foodplace.City.Country.CountryID);
|
||||
|
||||
ctx.Cities.Attach(city);
|
||||
ctx.Countries.Attach(country);
|
||||
ctx.FoodPlaces.Add(foodplace);
|
||||
ctx.SaveChanges();
|
||||
}
|
||||
|
|
|
@ -26,6 +26,15 @@ namespace Server.DB
|
|||
{
|
||||
using (Context ctx = new Context())
|
||||
{
|
||||
var city = ctx.Cities.FirstOrDefault(c => c.CityID == person.City.CityID);
|
||||
var country = ctx.Countries.FirstOrDefault(c => c.CountryID == person.City.Country.CountryID);
|
||||
var salutation = ctx.Salutations.FirstOrDefault(s => s.SalutationID == person.Salutation.SalutationID);
|
||||
var gender = ctx.Genders.FirstOrDefault(g => g.GenderID == person.Gender.GenderID);
|
||||
|
||||
ctx.Cities.Attach(city);
|
||||
ctx.Countries.Attach(country);
|
||||
ctx.Genders.Attach(gender);
|
||||
ctx.Salutations.Attach(salutation);
|
||||
ctx.Persons.Add(person);
|
||||
ctx.SaveChanges();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue