C
C#3y ago
DeaDo

Does AsNoTracking improve Performance in this Case?

public async Task<ItemDto?> GetAsync(int id)
{
return await Context.Items.AsNoTracking().Select(i => new ItemDto()
{
Id = i.Id,
Name = i.Name
}).FirstOrDefaultAsync(i => i.Id == id);
}
public async Task<ItemDto?> GetAsync(int id)
{
return await Context.Items.AsNoTracking().Select(i => new ItemDto()
{
Id = i.Id,
Name = i.Name
}).FirstOrDefaultAsync(i => i.Id == id);
}
3 Replies
DeaDo
DeaDoOP3y ago
Does AsNoTracking have any benefits if i write the object in a Dto immediately?
Patrick
Patrick3y ago
you already have it projected so no
DeaDo
DeaDoOP3y ago
Thanks
Want results from more Discord servers?
Add your server