다음 코드 단편에서 주문 관련 메모를 검색하고 있습니다. notetext
에 데이터가있는 경우에만 제대로 작동합니다. 자, 디버깅하는 동안 나는 그것을 발견했다. 다른 경우에는 Object reference not set to an instance of an object
이라는 예외를 throw한다.Entity.Contains (AttributeName)는 모든 주석 필드에서 작동하지만 notetext에서는 작동하지 않습니다.
다음 스 니펫이 좋아 보이지만 문제가 무엇인지 놓치지 않았는지 생각해보십시오.
private void fetchDocument(IOrganizationService service, Guid vOrderId)
{
EntityCollection results = null;
string tempNote = string.Empty;
string tempFileName = string.Empty;
ColumnSet cols = new ColumnSet("subject", "filename", "documentbody", "mimetype","notetext");
QueryExpression query = new QueryExpression {
EntityName = "annotation" ,
ColumnSet = cols,
Criteria = new FilterExpression
{
Conditions = {
new ConditionExpression("objectid",ConditionOperator.Equal,vOrderId)
}
}
};
results = service.RetrieveMultiple(query);
Entity defaultRecord = results.Entities.ElementAtOrDefault(0);
if(defaultRecord.Contains("notetext"))
{
tempNote = defaultRecord.GetAttributeValue<string>("notetext");
}
if (defaultRecord.Contains("filename"))
{
tempFileName = defaultRecord.GetAttributeValue<string>("filename");
}
}
하여 Null 참조 오류, 또는 :
Decomplied SDK 캐시기구 Serivce 상황에 맞는 여러 검색 :
Decomplied SDK는 여러 개의 코어를 검색 null입니까? – Daryl
여기에 excpetion이 throw됩니다. if (defaultRecord.Contains ("notetext")) " –