private bool FindClosestCandidateIndex()
{
_index = null;
_matchedCandidates = 0;
bool sortPriority = true;
_table._indexesLock.EnterUpgradeableReadLock();
try
{
int count = _table._indexes.Count;
int rowsCount = _table.Rows.Count;
for (int i = 0; i < count; i++)
{
Index ndx = _table._indexes[i];
if (ndx.RecordStates != _recordStates)
continue;
if (!ndx.IsSharable)
continue;
int match = CompareClosestCandidateIndexDesc(ndx._indexFields);
if (match > _matchedCandidates || (match == _matchedCandidates && !sortPriority))
{
_matchedCandidates = match;
_index = ndx;
sortPriority = CompareSortIndexDesc(ndx._indexFields);
if (_matchedCandidates == _nCandidates && sortPriority)
{
return true;
}
}
}
}
finally
{
_table._indexesLock.ExitUpgradeableReadLock();
}
return (_index != null ? sortPriority : false);
}