let me show you two different ways of updating a record I've stumbled upon:
Example 1:
List<ContentVersion> outs = new List<ContentVersion>();
List<ContentVersion> vers = [Select Id from ContentVersion where Custom_Field__c = 'ABC'];
for (ContentVersion ver : vers) {
ContentVersion out = new ContentVersion(
Id = ver.Id,
Custom_Field__c = 'XYZ');
outs.add(out);
}
update outs;
Example 2:
List<ContentVersion> outs = new List<ContentVersion>();
List<ContentVersion> vers = [Select Id from ContentVersion where Custom_Field__c = 'ABC'];
for (ContentVersion ver : vers) {
ver.Custom_Field__c = 'XYZ';
outs.add(ver);
}
update outs;
Could anyone explain to me if there is any difference and when to use the first technique and when the second one?