❔ Updating an entity/record with 1 query(?) on Entity Framework

My senior told me that there's a way to select and update something in EF in 1 query. So instead of this:
void MyMethod(int id)
{
    BundleRecord bundle = await databaseContext.Bundles.TagWithCallerName().SingleOrDefaultAsync(x => x.Id == id);
    bundle.ScanUploaded = true;

    await databaseContext.SaveChangesAsync();
}

He said, if he remembers correctly, I should use the Attach() method. I've been Googling, and this is how I understood how to use this method:
void MyMethod(int id)
{
    BundleRecord newBundle = new()
    {
        Id = id,
        ScanUploaded = true // eliminates the "bundle.ScanUploaded = true;" line?
    };

    databaseContext.Bundles.Attach(newBundle).State = EntityState.Modified;

    await databaseContext.SaveChangesAsync();
}

Just wondering if my approach and understanding of the Attach() method are correct.
Was this page helpful?