Tarik's example of getting all entities
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System;
using System.ServiceModel.Description;
using Microsoft.Crm.Sdk.Messages;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Client;
using Microsoft.Xrm.Sdk.Query;
using FCBT.CRM;
using Microsoft.Xrm.Sdk.Discovery;
using Microsoft.Xrm.Sdk.Messages;
using Microsoft.Xrm.Sdk.Metadata;
namespace CRMManager
{
class Program
{
private OrganizationDetail
CurrentOrganizationDetail { get; set; }
private IDiscoveryService
DiscoveryService { get; set; }
private IOrganizationService
OrgService { get; set;
}
static void Main(string[] args)
{
Uri OrganizationUri = new Uri("http://crmdevmt.develop.fcbt:5555/JamesDev/XRMServices/2011/Organization.svc");
ClientCredentials Credentials = new ClientCredentials();
Credentials.Windows.ClientCredential = new
System.Net.NetworkCredential("james", "mypassword", "mydomain");
//INITIALIZE PIPELINE SERVICE
OrganizationServiceProxy serviceProxy = new OrganizationServiceProxy(OrganizationUri,
null, Credentials, null);
serviceProxy.ServiceConfiguration.CurrentServiceEndpoint.Behaviors.Add(new ProxyTypesBehavior());
IOrganizationService service = (IOrganizationService)serviceProxy;
RetrieveAllEntitiesRequest req = new RetrieveAllEntitiesRequest();
req.EntityFilters = EntityFilters.Entity;
req.RetrieveAsIfPublished = true;
RetrieveAllEntitiesResponse response = (RetrieveAllEntitiesResponse) service.Execute(req);
List<string>
list = new List<string>();
foreach (var
item in response.EntityMetadata)
{
list.Add(item.LogicalName.ToUpper() + "
" + item.DisplayName.ToString().ToUpper());
}
list.Sort();
foreach (var
item in list)
{
Console.WriteLine(item);
}
}
}
No comments:
Post a Comment