I am trying to connect to MS CRM by CrmConnection ,OrganizationService classes but it says namespace missing please suggest a best class to connect to MS CRM easily
CrmConnection connection = CrmConnection.Parse(con);
using (Microsoft.Xrm.Client.Services.OrganizationService orgService = new Microsoft.Xrm.Client.Services.OrganizationService(connection))
{
//using (_serviceProxy = new OrganizationServiceProxy(
// oUri, null, clientCredentials, null))
//{
string fetch3 = @"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>
<entity name='lead'>
<attribute name='fullname' />
<attribute name='companyname' />
<attribute name='telephone1' />
<attribute name='leadid' />
<attribute name='mobilephone' />
<order attribute='fullname' descending='false' />
<filter type='and'>
<condition attribute='fullname' operator='not-null' />
<condition attribute='mobilephone' operator='not-null' />
</filter>
</entity>
</fetch>";
EntityCollection result = _serviceProxy.RetrieveMultiple(new FetchExpression(fetch3));
// EntityCollection result = _service.RetrieveMultiple(new FetchExpression(fetchXml));
foreach (var item in result.Entities)
{
Lead lea = new Lead();
lea.firstname = item.Attributes["fullname"].ToString();
lea.mobile = item.Attributes["mobilephone"].ToString();
leadlist.Add(lea);
}
}
}
catch (Exception ex)
{
string result = "Exception: " + ex.Message;
}
return leadlist;
}