Adding Data into tables iclueds Foreign Keys but Which New Row created Entity FrameWork ?
Posted
by programmerist
on Stack Overflow
See other posts from Stack Overflow
or by programmerist
Published on 2010-04-06T09:04:04Z
Indexed on
2010/04/06
9:33 UTC
Read the original article
Hit count: 267
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?
© Stack Overflow or respective owner