I am querying a SqLite database using EntityFramework.Sqlite 7.0.0-rc1-final. The following method is the code in question:
using (var db = new SfpDb.Ctx())
{
int baneLokId = db.tabStevne.First(a => a.Id == id).BaneLokId;
Console.WriteLine("baneLokId: " + baneLokId.ToString());
IQueryable<int> baneTypeIds = db.tabBane.Where(o => o.BaneLokId == baneLokId).Select(n => n.BaneTypeId);
List<SfpDb.HovedOvelse> testList = new List<SfpDb.HovedOvelse>();
foreach (int i in baneTypeIds)
{
Console.WriteLine("baneTypeIds: " + i);
testList.AddRange(db.tabHovedOvelse.Where(p => p.BaneTypeId == i));
foreach (SfpDb.HovedOvelse h in db.tabHovedOvelse.Where(p => p.BaneTypeId == i).OrderBy(k=>k.navn))
{
Console.WriteLine("\t" + h.navn);
}
}
return db.tabHovedOvelse.Where(p => baneTypeIds.Contains(p.BaneTypeId)).ToList();
}
If calling this method twice with different input (id), the first return value is correct, but the in the second call, the return value is identical to the first call, regardless what the input (id) is. The "testList" does however contain the correct info in all calls.
Is there some kind of cache that needs to be cleared when using EF?
Aucun commentaire:
Enregistrer un commentaire