Entity Framework 6とToListAsync()/ ToList()に関する質問があります。Entity Framework 6とAsync()のパフォーマンス
データ量が少ない(約1000行)場合、ToListAsync()はToList()よりも高速です。
しかし、私は膨大な量のデータ(約600.000行)を持っていれば、ToList()はToListAsync()より高速です。
ここであなたはコードを細かくすることができます、誰かが私の理由を説明することができますか?私はいくつかの有用な記事を発見した.But
//SharedAnagra contains around 1000 rows
static List<SharedAnagra> GetSharedAnagraList()
{
using (Intranet2k3Entities intranet2K3Entities = new Intranet2k3Entities())
{
List<SharedAnagra> listaSharedAnagras = (from a in intranet2K3Entities.sharedAnagra
select new SharedAnagra
{
AnagraActive = a.AnagraActive,
AnagraId = a.AnagraID,
AnagraName = a.AnagraName,
OfficeId = a.OfficeID
}).ToList();
return listaSharedAnagras;
}
}
static async Task<List<SharedAnagra>> GetSharedAnagraListAsync()
{
using (Intranet2k3Entities intranet2K3Entities = new Intranet2k3Entities())
{
List<SharedAnagra> listaSharedAnagras = await (from a in intranet2K3Entities.sharedAnagra
select new SharedAnagra
{
AnagraActive = a.AnagraActive,
AnagraId = a.AnagraID,
AnagraName = a.AnagraName,
OfficeId = a.OfficeID
}).ToListAsync();
return listaSharedAnagras;
}
}
//sharedAnagraNDGClienti contains 950000 rows
static List<SharedAnagraNdgClienti> ListaSharedNdgClienti()
{
using (Intranet2k3Entities intranet2K3Entities = new Intranet2k3Entities())
{
List<SharedAnagraNdgClienti> lista = (from a in intranet2K3Entities.sharedAnagraNDGClienti
select new SharedAnagraNdgClienti
{
Cm = a.CM,
CodFisc = a.CodFisc,
Cognome = a.Cognome,
Descrizione = a.Descrizione,
FilialePrevalente = a.Filiale_Prevalente,
Ndg = a.NDG,
Nome = a.Nome,
Telefono = a.Telefono,
Tipologia = a.Tipologia,
Trae = a.TRAE,
Tsae = a.TSAE
}).AsNoTracking().ToList();
return lista;
}
}
static async Task<List<SharedAnagraNdgClienti>> GetIssueTypeByIdAsync()
{
List<SharedAnagraNdgClienti> listaSharedAnagraNdgClienti;
using (Intranet2k3Entities intranet2K3Entities = new Intranet2k3Entities())
{
listaSharedAnagraNdgClienti = await (from a in intranet2K3Entities.sharedAnagraNDGClienti
select new SharedAnagraNdgClienti
{
Cm = a.CM,
CodFisc = a.CodFisc,
Cognome = a.Cognome,
Descrizione = a.Descrizione,
FilialePrevalente = a.Filiale_Prevalente,
Ndg = a.NDG,
Nome = a.Nome,
Telefono = a.Telefono,
Tipologia = a.Tipologia,
Trae = a.TRAE,
Tsae = a.TSAE
}).AsNoTracking().ToListAsync();
}
return listaSharedAnagraNdgClienti;
}