I've made code to check if a record in CRM exists. Problem is that the IOrganisationService.Retrieve returns an error instead of a null when no record is found. I expect multiple records not to be found and I do not want to have to use a try catch then use the error from the 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
}
Suggestions?