The Microsoft Dynamics CRM Type Provider Sample: Static Parameters

[ Update: the CRM type provider is now available as the FSharpx.TypeProviders.Xrm NuGet package, part of the FSharpx library. The namespace has changed from "Samples" to "FSharpx" ]

Part 1 - The Microsoft Dynamics CRM Type Provider Sample
Part 2 - The Microsoft Dynamics CRM Type Provider Sample - Static Parameters
Part 3 - The Microsoft Dynamics CRM Type Provider Sample - Updated Functionality

The CRM Type Provider Sample in the F# 3.0 Sample Pack supports several interesting static parameters that determine how CRM is integrated into the F# programming language.

The parameters are as follows:

OrganizationServiceUrl

The service URL for the CRM Organization Service

(required)

UseNullableValues

When true, attributes in CRM that are not required will be surfaced as Nullable<'T>. When false, all value-type, non required attributes will be returned as Unchecked.defaultOf<'T> whether they exist or not

default: false

RelationshipNamingType

Determines the naming convention of relationship properties used on entity types

default: ParentChildPrefix

CrmOnline

When true, Windows Live authentication will be used, allowing access to CRM Online deployments

default: false

CredentialsFile

Path to a plain text file that includes username, password and optionally the domain. In the case of CRM Online these would be the relevant Windows Live username and password

default: ""

Username

Can be used in explorative scripting scenarios instead of a credentials file

default: ""

Password

Can be used in explorative scripting scenarios instead of a credentials file

default: ""

Domain

Can be used in explorative scripting scenarios instead of a credentials file

default: ""

IndividualsAmount

The maximum number of sample individuals for each CRM entity set

default: 1000

DataBindingMode

Controls the behaviour of data bound entities

default: NormalValues

 

Some further rules of the authentication configuration are as follows:

  • If you do not supply credentials, Active Directory will be used for authentication. Where at all possible, this is the recommended approach.

  • At runtime, you are able to pass in a different service endpoint and / or credentials by using the various GetDataContext method overloads.

  • In a compiled application, passing credentials as static parameters will always require you to supply them again in the GetDataContext method. This is to ensure no credentials appear in the resulting binaries. This restriction does not apply whilst working in F# interactive.

  • If you require credentials as static parameters, but would like to use Active Directory at runtime, you can pass blank strings for username, password and domain into the GetDataContext method.

     

Of the static parameters only the service URL is required. You can supply others you need with the named parameter syntax:

 

type Xrm = XrmDataProvider<"https://server/org/XRMServices/2011/Organization.svc", CredentialsFile="Credentials.txt">

 

let dc = Xrm.GetDataContext()