CrmAuthenticationToken token = new CrmAuthenticationToken();
token.OrganizationName = "";
token.AuthenticationType = 0;
Microsoft.Crm.SdkTypeProxy.CrmService service = new Microsoft.Crm.SdkTypeProxy.CrmService();
service.Url= "http://localhost:5555/mscrmservices/2007/crmservice.asmx";
service.CrmAuthenticationTokenValue = token;
service.Credentials = System.Net.CredentialCache.DefaultCredentials;
service.UnsafeAuthenticatedConnectionSharing = true;
Microsoft.Crm.Sdk.Query.QueryExpression query = new Microsoft.Crm.Sdk.Query.QueryExpression("mycustomentity");
query.ColumnSet.AddColumn("mycustomentityid");
query.ColumnSet.AddColumn("name");
query.ColumnSet.AddColumn("number");
query.Criteria.AddCondition("name", ConditionOperator.Equal, "Chandresh");
RetrieveMultipleRequest requestAccount = new RetrieveMultipleRequest();
requestAccount.Query = query;
requestAccount.ReturnDynamicEntities = true;
RetrieveMultipleResponse result = (RetrieveMultipleResponse)_crmService.Execute(requestAccount);
if (result.BusinessEntityCollection.BusinessEntities.Count > 0)
{
DynamicEntity myEntity = (DynamicEntity)result.BusinessEntityCollection.BusinessEntities[0];
string strName = "";
string intNumber = 0;
if (myEntity.Properties.Contains("number"))
intNumber = ((CrmNumber)myEntity.Properties["number"]).Value;
if (myEntity.Properties.Contains("name"))
intNumber = myEntity.Properties["name"]).ToString();
}
Comments