/Plugin
//获取context
IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
//获取organizationService
IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
IOrganizationService userService = serviceFactory.CreateOrganizationService(context.UserId);
//获取entity
//Create
Entity entity = (Entity)context.InputParameters["Target"];
//Delete
EntityReference er = context.InputParameters["Target"] as EntityReference;
Entity entity = organizationService.Retrieve(er.LogicalName, er.Id, new ColumnSet(true));
//Retrieve
Entity entity = (Entity)context.OutputParameters["BusinessEntity"];
//抛出异常
throw new InvalidPluginExecutionException("Error");