【发布时间】:2016-10-10 08:45:23
【问题描述】:
我编写了代码来检查 CRM 中的记录是否存在。问题是 IOrganisationService.Retrieve 在找不到记录时返回错误而不是 null。我希望找不到多条记录,并且我不想使用 try catch 然后使用 catch 中的错误。
using (OrganizationServiceProxy serviceProxy = new OrganizationServiceProxy(OrganizationUri, HomeRealmUri, credentials, null))
{
IOrganizationService service = (IOrganizationService)serviceProxy;
//Get record
var record = service.Retrieve(entryId, guid, new ColumnSet(true)); //switch to var if no work
//Check if record is not null/empty
recordExists = !String.IsNullOrWhiteSpace(record.Id.ToString()); //<- does the record exist
}
建议?
【问题讨论】:
-
为什么不想使用 try/catch?请参阅我的答案寻求帮助。
标签: c# dynamics-crm dynamics-crm-2013