Hiii. i write just simple queryepression from the tutorial. The code looks like below:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Xrm.Sdk;
using System.ServiceModel;
using Microsoft.Xrm.Sdk.Query;
namespace ClassLibrary4
{
public class Class1 : IPlugin
{
public void Execute(IServiceProvider serviceprovider)
{
IPluginExecutionContext context = (IPluginExecutionContext)serviceprovider.GetService(typeof(IPluginExecutionContext));
IOrganizationServiceFactory servicefactory = (IOrganizationServiceFactory)serviceprovider.GetService(typeof(IOrganizationServiceFactory));
IOrganizationService service = (IOrganizationService)serviceprovider.GetService(typeof(IOrganizationService));
if(context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity)
{
Entity entity = (Entity)context.InputParameters["Target"] as Entity ;
if (entity.LogicalName != "new_callistyorder")
return;
if (context.MessageName.ToLower() == "update")
{
QueryExpression query = new QueryExpression { EntityName = "new_callistyorder",
ColumnSet = new ColumnSet("new_nomororder") };
EntityCollection colect = service.RetrieveMultiple(query);
string str = string.Empty;
foreach (Entity e in colect.Entities)
{
str = str + e.Attributes["new_nomororder"].ToString();
}
throw new InvalidPluginExecutionException(str);
}
}
}
}
}
After register this code to CRM. It give me error message like this:
Can anybody please tell me what wrong with those code and how can i fix this problem
Thanks
