This is a follow up to my previous post Microsoft Dynamics CRM 2011 Online Integration Getting Started (Late Bound). Here I list the steps that I had to do different to work with early binding.
After creating the project, I ran CrmSvcUtil.exe:
<location of sdk>\bin\CrmSvcUtil.exe /url:https://xxx.api.crm4.dynamics.com/XRMServices/2011/Organization.svc /out:”C:\Users\henols02\Documents\Visual Studio 2010\Projects\<project name>\Models\CrmModel.cs” /namespace:<project name>.Models /serviceContextName:CrmServiceContext /username:”<Windows Live ID” /password:”<password>”
and added the resulting CrmModel.cs to the project in the Models folder.
After creating the service proxy (in LogOn method), early bound support had to be added using the following statement:
In the created controller, getting the context and retrieving the data is done in a slightly different (simpler) way:
var context = new Elevregister1.Models.CrmServiceContext(service);
var elever = context.elev_elevSet.ToList();
I created the view as a strongly-type view:
Then, I removed the unwanted columns.