LC0081 - StefanMaron/BusinessCentral.LinterCop GitHub Wiki
IsEmpty()
for checking record existence.
Use Rec.The Rec.Count()
function can be an expensive operation, especially on large tables, as it performs a full table or index scan to count all records in the database. This can significantly degrade performance and unnecessarily load the database.
Instead of Rec.Count() to check for the presence of records, use the more efficient Rec.IsEmpty()
function. Unlike Rec.Count(), Rec.IsEmpty() stops immediately after finding a single record, reducing database load and improving performance.
Checking for no records
if Rec.Count() = 0 then
Should be replaced by
if Rec.IsEmpty() then
Checking for any records
if Rec.Count() > 0 then
Should be replaced by
if not Rec.IsEmpty() then