I´m trying to do 2 linq insert queries. The second one needs the last inserted id value from the first query.
How can I get the last_id_inserted (last_fich)?
db.CWC_FICHEIROS.Add(new CWC_FICHEIROS
{
idfiletype = newextID,
filename = fileName,
fileurl = fileName,
fileordem = "AA001",
filedate = System.DateTime.Now,
fileact = true
});
last_fich = db.CWC_FICHEIROS.Max(item => item.id_file);
db.CWC_FILESSUBCONTEUDOS.Add(new CWC_FILESSUBCONTEUDOS
{
idfile = last_fich,
idsubconte = cwc_subconteudos.idcont,
fscact = true
});
db.SaveChanges();
Like it is, last_fich
gives me the id of the first row of CWC_FICHEIROS
.