다음을 통해 공유


초기 및 런타임에 바인딩 엔터티 혼합

 

게시 날짜: 2016년 11월

적용 대상: Dynamics CRM 2015

Microsoft Dynamics 365에서 초기 바인딩 및 런타임에 바인딩 메서드를 혼합하여 둘 다 강력한 유형 및 Entity 클래스와 함께 작업할 수 있습니다. 이 방식은 Entity 클래스의 유연성과 함께 강력한 유형의 코드 생성 파일의 정적 메타데이터와 도우미 메서드를 둘 다 사용합니다.

다음 예제에서는 초기 바인딩 및 런타임에 바인딩 방법을 혼합하는 한 가지 방법을 보여 줍니다.

// Create an organization service context object
AWCServiceContext context = new AWCServiceContext(_serviceProxy);

// Instantiate an account object using the Entity class.
Entity testaccount = new Entity("account");

// Set several attributes. For account, only the name is required. 
testaccount["name"] = "Fourth Coffee";
testaccount["emailaddress1"] = "marshd@contoso.com";

// Save the entity using the organization service context object.
context.AddToAccountSet(testaccount);
context.SaveChanges();





초기 바인딩된 인스턴스를 런타임에 바인딩된 인스턴스에 할당

다음 샘플에서는 초기 바인딩된 인스턴스를 런타임에 바인딩된 인스턴스에 할당하는 방법을 보여 줍니다.

Entity incident = ((Entity)context.InputParameters[ParameterName.Target]).ToEntity<Incident>();
Task relatedEntity = new Task() { Id = this.TaskId };

incident.RelatedEntities[new Relationship("Incident_Tasks")] = 
new EntityCollection(new Entity[] { relatedEntity.ToEntity<Entity>() });

참고 항목

코드에 초기 바인딩 엔터티 클래스 사용
코드에 런타임에 바인딩 엔터티 클래스 사용
샘플: 조직 서비스 컨텍스트 사용

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