Home
Options

How to update data based on valid foreign key values

Hi I am new to the tool, and excited about using it, considering getting it. I searched for save and did not find any threads on saving data in query.

Simple Tables with FK keys:

  1. BuildingTable: Id, BldName                                 e.g. [Bldg 102, Bldg103, ... ]
  2. PoepleTable:   Id, BuildingId (FK key)                  e.g [John 102, Smith 103]
  3. PetTypeTable:  Id, TypeDogCat, OwnerId (FK key to peopleId who own the dog or cat), BuildingId (FK key)
  4. PetNameTable:   Id, DogName, PetTypeTableId (FK key)   e.g [1 Caesar Dog, 2 Candy Cat]

Question: I am trying to create pets names records. But first, how can I populate the PetTable with valid OwnerId & BuildingId

 


 PetTable
.Where(x=> x.BuildingId  == PoepleTable.BuildingId  )
.GroupBy(x => x.TypeDogCat)

//How to populate/update this in Linq pad

.Update(x => x = PoepleTable.Id)

// how to Update and save

PetNameTable.Where(petRecord => petRecord.Name = Random(PetName) && petRecord.PetTypeTableId = RandomValidPetType);

db.SubmitChanges();??
Sign In or Register to comment.