Description

List name is culture specific string or could be changed later:

  • Avoid string based index calls to obtain the list.
  • Avoid using TryGetList method for the List access.

Potential performance issues:

  • Avoid all list enumerations via enumerator calls.
  • Avoid all list enumerations via linq Cast expression.
  • Avoid all list enumerations via linq OfType expression.

Inappropriate usage:

code.png

Resolution

Consider retrieving list by its URL with SPWeb.GetList() method


var listUrl = "/lists/tasks";
var taskList = web.GetList(SPUrlUtility.CombineUrl(web.Url, listUrl));


Links