The Microsoft Dynamics CRM Type Provider Sample: Static Parameters

The Microsoft Dynamics CRM Type Provider Sample: Static Parameters

  • Comments 4

[ 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<"http://server/org/XRMServices/2011/Organization.svc", CredentialsFile="Credentials.txt">

 

let dc = Xrm.GetDataContext()

Leave a Comment
  • Please add 4 and 3 and type the answer here:
  • Post
  • Dear,

    This first release is an excellent take of contact, but if we want to use as alternative of the C# language we need to include new features like joins, in fact the limitations that you said on last post:

    • Explicit joins are not implemented

    • Many to many relationships to/from the same entity type are not implemented

    • Aggregation operations are not implemented

    • No support for formatted values and option set types is implemented

    • There are some restrictions with the way parents / children can be selected (more on this in later posts)

    • The provider is designed thus far to extract data, not push data back in. Whilst the resulting entities can be used like any normal CRM entity, you may not use the strongly typed attributes and relationships to modify or create new data. You can however still use the underlying Entity object like normal for this purpose.

    • A connection to the organization service is required during compilation

    Do you have any intention to continue improvement this great Type Provider?

  • Isn't there a problem with the latest version (some issues because of renaming)?

    *** I got the latest page with help of NuGet:

    PM> Install-Package FSharpx.TypeProviders.Xrm

    Successfully installed 'FSharpx.TypeProviders.Xrm 1.7.11'.

    Successfully added 'FSharpx.TypeProviders.Xrm 1.7.11' to ConsoleApplicationXrm.

    *** I added code as described:

    open System

    open System.Linq

    open FSharpx.TypeProviders

    open FSharpx.TypeProviders.XrmProvider

    [<EntryPoint>]

    let main argv =

       [<Literal>]

       let url = "http://[FQDN_TO_SERVER]/[ORGANIZATION]/XRMServices/2011/Organization.svc"

       let user = "[USERNAME]"

       let password = "[PASSWORD]"

       let domain = "[DOMAIN]"

       let xrm_ = XrmDataProvider<

                   OrganizationServiceUrl = url,

                   Username = user,

                   Password = password,

                   Domain = domain >.GetDataContext(url, user, password, domain, false)

       let accounts = xrm.account

       0

    *** But I get this error. I suppose is regarding the renaming from Sample to FSharpx:

    Error 1 The type provider 'FSharpx.TypeProviders.XrmProvider.XrmTypeProvider' reported an error: Member Samples.FSharp.ProvidedTypes.ProvidedConstructor is of unexpected type C:\_tfs\_xprototypes\ConsoleApplicationXrm\ConsoleApplicationXrm\Program.fs 33 5 ConsoleApplicationXrm

    Hope you can help and keep up the good work guys :D

  • Hi Ramon,

    please try 1.7.12 from nuget.

    Thanks.

  • Hello Ramón , the bug you reported is now fixed, there is a new version of the nuget package : FSharpx.TypeProviders.Xrm 1.7.12

    Some code had got out of sync between the various repositories, thanks for the bug report.

    Ross

Page 1 of 1 (4 items)