다음을 통해 공유


조직 서비스 메서드

 

게시 날짜: 2017년 1월

적용 대상: Dynamics 365 (online), Dynamics 365 (on-premises), Dynamics CRM 2016, Dynamics CRM Online

IOrganizationService 웹 서비스는 시스템 및 사용자 지정 엔터티와 조직의 메타데이터에서 가장 일반적인 작업을 수행하는 데 사용되는 메서드 집합을 제공합니다. 이러한 작업은 IOrganizationService.Execute 메서드와 해당 메시지를 사용하여 수행할 수 있습니다.

만들기

IOrganizationService.Create 메서드를 사용하여 사용자 지정 엔터티를 포함하여 Create 메시지를 지원하는 엔터티의 인스턴스(레코드)를 만듭니다.

검색

IOrganizationService.Retrieve 메서드를 사용하여 엔터티의 인스턴스(레코드)를 검색합니다.

RetrieveMultiple

IOrganizationService.RetrieveMultiple 메서드를 사용하여 컬렉션 레코드를 검색합니다. 쿼리 식 또는 Fetch XML 쿼리를 사용하여 쿼리를 지정할 수 있습니다.

Update

IOrganizationService.Update 메서드를 사용하여 기존 레코드를 업데이트합니다.

Delete

IOrganizationService.Delete 메서드를 사용하여 기존 레코드를 삭제합니다.

Associate

IOrganizationService.Associate 메서드를 사용하여 관계에 참여하는 두 레코드 간의 링크를 만듭니다.

Disassociate

IOrganizationService.Disassociate 메서드를 사용하여 두 레코드 간의 링크를 삭제합니다.

실행

IOrganizationService.Execute 메서드를 사용하여 메시지를 실행합니다. 여기에는 데이터 레코드 만들기와 삭제와 같은 일반적인 처리가 포함됩니다. 또는 가져오기 또는 중복 검색과 같은 처리를 전문으로 할 수 있습니다.

예제

다음 코드에서는 강력한 유형을 사용하여 Create, RetrieveUpdate 메서드를 사용하는 방법을 보여 줍니다.


//Define the account for which we will add letters                
Account accountToCreate = new Account
{
    Name = "Example Account"
};

//Define the IDs of the related letters we will create
_letterIds = new[] { Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid() };

//This acts as a container for each letter we create. Note that we haven't
//define the relationship between the letter and account yet.
EntityCollection relatedLettersToCreate = new EntityCollection
{
    EntityName = Letter.EntityLogicalName,
    Entities =
    {
        new Letter{Subject = "Letter 1", ActivityId = _letterIds[0]},
        new Letter{Subject = "Letter 2", ActivityId = _letterIds[1]},
        new Letter{Subject = "Letter 3", ActivityId = _letterIds[2]}
    }
};

//Creates the reference between which relationship between Letter and
//Account we would like to use.
Relationship letterRelationship = new Relationship("Account_Letters");

//Adds the letters to the account under the specified relationship
accountToCreate.RelatedEntities.Add(letterRelationship, relatedLettersToCreate);

//Passes the Account (which contains the letters)
_accountId = _service.Create(accountToCreate);

Console.WriteLine("An account and {0} letters were created.", _letterIds.Length);


//Now we run through many of the same steps as the above "Create" example
Account accountToUpdate = new Account
{
    Name = "Example Account - Updated",
    AccountId = _accountId
};

EntityCollection relatedLettersToUpdate = new EntityCollection
{
    EntityName = Letter.EntityLogicalName,
    Entities =
    {
        new Letter{Subject = "Letter 1 - Updated", ActivityId = _letterIds[0]},
        new Letter{Subject = "Letter 2 - Updated", ActivityId = _letterIds[1]},
        new Letter{Subject = "Letter 3 - Updated", ActivityId = _letterIds[2]}
    }
};

accountToUpdate.RelatedEntities.Add(letterRelationship, relatedLettersToUpdate);

//This will update the account as well as all of the related letters
_service.Update(accountToUpdate);
Console.WriteLine("An account and {0} letters were updated.", _letterIds.Length);

참고 항목

IOrganizationService
조직 서비스를 사용하여 데이터 또는 메타데이터 읽고 씁니다.
Execute 메서드와 함께 메시지(요청 및 응답 클래스) 사용
ExecuteMultiple을 사용하여 대량 데이터 로드 성능 향상
조직 서비스의 xRM 메시지
조직 서비스의 Dynamics 365 메시지
Microsoft Dynamics 365에서 사용자 인증
샘플: 레코드 만들기, 검색, 업데이트 및 삭제(초기 바인딩)
샘플: 만들기, 검색, 업데이트 및 삭제(런타임에 바인딩)

Microsoft Dynamics 365

© 2017 Microsoft. All rights reserved. 저작권 정보