2016-07-21 3 views
1

"Dyanmics CRM 2016"에서 정보를 가져 오기 위해 콘솔 응용 프로그램을 만들었습니다. XrmServiceContext을 사용하여 데이터를 가져오고 다른 엔티티에서 정보를 가져올 수 있지만 특정 속성에 따라 EmailSet을 가져 오는 경우 문제가 있습니다.CRM 2016 RegardingObjectId.Name의 전자 메일 얻기

내 코드 :

//This works 
var test= context.EmailSet.FirstOrDefault(e => e.RegardingObjectId.Id == Guid); 
//This doesn't work 
var test= context.EmailSet.FirstOrDefault(e => e.RegardingObjectId.Name == "somename");  

이 라인은 예외를 던지고있다 :

"Invalid 'where' condition. An entity member is invoking an invalid property or method." 

질문 :RegardingObjectId.Name에 의해 EmailSet를 조회 할 수 있습니까?

본인은이 속성에 대해 특별한 것을 보지 못해서 누군가가 나를 도와 줄 수 있기를 바랍니다.

답변

0

불행히도 Linq에는 CRM에는 몇 가지 단점이 있지만 더 유연한 fetchxml을 사용할 수 있습니다.

var results = service.RetrieveMultiple(
        new FetchExpression(
         string.Format("<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>" + 
         "<entity name='email'>" + 
         "<attribute name='subject' />" + 
         "<filter type='and'>" + 
         "<condition attribute='regardingobjectidname' operator='eq' value='{0}' />" + 
         " </filter>" + 
         "</entity>" + 
         "</fetch>", "foobar"))); 

var emails = results == null 
    ? new List<Email>() 
    : results.Entities.Cast<Email>();