我正在尝试整合Dynamics Crm 2015.在这篇文章Integration to Microsoft Dynamic CRM 2011的帮助下,我写了这段代码:
Dictionary<string, string> parameters = GetCustomParameters(company.Id);
Uri uri = new Uri(parameters["serviceUrl"]);
var username = parameters["username"];
var password = parameters["password"];
var entity = parameters["entity"];
ClientCredentials credentials = new ClientCredentials();
credentials.UserName.UserName = username;
credentials.UserName.Password = password;
OrganizationServiceProxy osproxy = new OrganizationServiceProxy(uri, null, credentials, null);
IOrganizationService _services = (IOrganizationService)osproxy;
QueryExpression query = new QueryExpression()
{
EntityName = entity,
ColumnSet = new ColumnSet("firstname", "lastname", "emailaddress")
};
EntityCollection retrieved = _services.RetrieveMultiple(query);
执行此操作时,会提示:
值不能为空。\ r \ nParameter name:detail
任何帮助将不胜感激。我以前没有CRM集成的经验。
答案 0 :(得分:0)
此QueryExpression测试可以像CRM 2016一样工作
这是一个例子
ConditionExpression condicion1 = new ConditionExpression();
condicion1.AttributeName = "name";
condicion1.Operator = ConditionOperator.NotNull;
FilterExpression filtro = new FilterExpression();
filtro.Conditions.Add(condicion1);
filtro.FilterOperator = LogicalOperator.And;
QueryExpression consulta = new QueryExpression("account");
consulta.Criteria.AddFilter(filtro);
consulta.ColumnSet = new ColumnSet("name", "telephone1");
EntityCollection resultados = service.RetrieveMultiple(consulta);
foreach (Entity c in resultados.Entities)
{
Console.WriteLine("{0} | {1}", c["name"].ToString(), c["telephone1"].ToString());
}
Console.Read();