/// <summary> /// Retrieves the first Active entity where the columnNameAndValue Pairs match /// </summary> /// <typeparam name="T">An early bound Entity Type</typeparam> /// <param name="service">open IOrganizationService</param> /// <param name="columnNameAndValuePairs">List of pairs that look like this: /// (string name of the column, value of the column) ie. "name","John Doe" goes to entity.name = "John Doe" /// </param> /// <returns></returns> public static T GetFirstOrDefault <T>(this IOrganizationService service, params object[] columnNameAndValuePairs) where T : Entity { var settings = new QuerySettings <T> { First = true }; return(service.GetEntities <T>(settings.CreateExpression(columnNameAndValuePairs)).FirstOrDefault()); }
private static BulkDeleteOperation GetBulkDeleteOperation(IOrganizationService service, Guid asyncId) { var settings = new QuerySettings <BulkDeleteOperation>() { ActiveOnly = false, Columns = new ColumnSet("failurecount", "successcount", "statecode", "statuscode", "bulkdeleteoperationid", "asyncoperationid"), First = true }; return(service.RetrieveList <BulkDeleteOperation>(settings.CreateExpression("asyncoperationid", asyncId)).FirstOrDefault()); }
private static BulkDeleteOperation GetBulkDeleteOperation(IOrganizationService service, Guid asyncId) { var settings = new QuerySettings<BulkDeleteOperation>() { ActiveOnly = false, Columns = new ColumnSet("failurecount", "successcount", "statecode", "statuscode", "bulkdeleteoperationid", "asyncoperationid"), First = true }; return service.RetrieveList<BulkDeleteOperation>(settings.CreateExpression("asyncoperationid", asyncId)).FirstOrDefault(); }