protected virtual ConcurrentDictionary<string, EksternDeltakerPosisjon> HentFraDatabasen()
{
//using (With.ReadUncommitted())
using (var context = _dataContextFactory.Create())
{
var sistePosisjoner = from p in context.DeltakerPosisjoner
group p by p.DeltakerId
into g
select g.OrderByDescending(x => x.Tidspunkt).FirstOrDefault();
var alle = sistePosisjoner.ToList().Select(siste => new DeltakerPosisjon
{
DeltakerId = siste.DeltakerId,
LagId = siste.LagId,
Latitude = siste.Latitude,
Longitude = siste.Longitude,
Tidspunkt = siste.Tidspunkt
}).Select(TilEksternDeltakerPosisjon);
var dictionary = alle.ToDictionary(x => x.DeltakerId, x => x);
return new ConcurrentDictionary<string, EksternDeltakerPosisjon>(dictionary);
}
}