Adding Data into tables iclueds Foreign Keys but Which New Row created Entity FrameWork ?
- by programmerist
Addding Data into kartlar Table (RehberID,KampanyaID,BrimID) is ok. But Which Kart'ID created? i need to learn Which Id created after Adding Data (RehberID,KampanyaID,BrimID) into Kartlar?
public static List<Kartlar> SaveKartlar(int RehberID, int KampanyaID, int BrimID, string Notlar)
{
using (GenSatisModuleEntities genSatisCtx = new GenSatisModuleEntities())
{
Kartlar kartlar = new Kartlar();
kartlar.RehberReference.EntityKey = new System.Data.EntityKey("GenSatisModuleEntities.Rehber", "ID", RehberID);
kartlar.KampanyaReference.EntityKey = new System.Data.EntityKey("GenSatisModuleEntities.Kampanya", "ID", KampanyaID);
kartlar.BirimReference.EntityKey = new System.Data.EntityKey("GenSatisModuleEntities.Birim", "ID", BrimID);
kartlar.Notlar = Notlar;
genSatisCtx.AddToKartlar(kartlar);
genSatisCtx.SaveChanges();
List<Kartlar> kartAddedPatient;
kartAddedPatient = (from k in genSatisCtx.Kartlar
where k.RehberReference.EntityKey == RehberID &&
k.KampanyaReference.EntityKey == KampanyaID &&
k.BirimReference.EntityKey == BrimID
select k)
return kartAddedPatient ;
}
}
How can i do that? i want to get data from Kartlar which data i added?