문제

CSOM을 사용하여 목록을 얻는 가장 좋은 방법은 무엇입니까?

몇 가지 관련 질문 :

  • 항상 모든 목록을 먼저 반환 한 다음 Linq 쿼리를 실행하여 올바른 것을 선택 하시겠습니까?
  • 목록을 얻기 위해 어떤 재산을 사용해야합니까?제목 (적어도 이론적으로)을 변경할 수 있고 GUID가 환경 (Dev / Test / QA / On-Premises / O365) 사이에서 어려워 지므로 제목이나 GUID 대신 URL 이름 (/ myList /) 대신 URL 이름 (/ myList /)을 사용하고 싶습니다.이 URL 이름 (웹 URL 없음) 에 대한 속성이 있습니까?
  • 는 대부분의 시나리오에서 가장 빠른 접근법이 될 것입니까?

    제안 된 해결책 뒤에 어떤 추론을하고 싶습니다.

도움이 되었습니까?

해결책

As always it depends.

  • Getting the list by title will give you the best performance as the ListCollection.GetByTitle doesn't even require a trip to the server before you can use the list. But it has the downside that the user can easily change the title and make your code fail.

  • Getting the list by Url or Id will require you to retrieve these properties for all list which require a round trip to the server. Using the Url (relative) will work across sites, but the user has the possibility of moving the list which will then again break your code.

In cases where I can't trust the users not to change things they should leave alone and on the other hand I need to be able to have the code working as stable as possible across sites I've used the approach of:

  • storing Id and Url in a web.property (assume Guid.Empty and default url if nothing is stored)
  • retrieve Id and Url of all lists
  • if any Id match use that list (and update the property if the Url isn't right)
  • if no Id match by an Url does use that list and update Id
  • if no Id nor Url match then cry
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 sharepoint.stackexchange
scroll top