Randoom a Michael Friis production

Posted
13 December 2008 @ 7pm

Categories
Dynamics CRM, LINQ

Tagged
, , , ,

You're reading Randoom, a Michael Friis production

Querying relationships with LinqtoCRM

I’ve just recorded a web cast demontrating joins with LinqtoCRM. The piece de resistance is a join across a many-to-many relationship with the intermediary class generated by CRMMetal:

var res = from u in p.Linq()
	join sr in p.Linq() on u.systemuserid.Value equals sr.systemuserid.Value
	join r in p.Linq() on sr.roleid.Value equals r.roleid.Value
        select new { u.fullname, r.name };

The equivalent example query in the CRM SDK is around forty lines, compared to four for LinqtoCRM. Watch the web cast here.


8 Comments

Posted by
Guil
19 December 2008 @ 11am

Good stuff :)

Do you plan to add support to custom entities?

Cheers,


Posted by
friism
20 December 2008 @ 5pm

@Guil, custom entities are supported out of the box, the example just uses a standard entity for common frame of reference.


[...] and instead provide their own class generator/entity mapper (LinqtoCRM has one too, but only for generating many-to-many classes). This means you can’t mix and match Linq with traditional web service calls, and they had to [...]


Posted by
brenden
27 May 2009 @ 12am

I have an example below of code I have tried to use that is very similar to your demo. It compiles and it authenticates but when the result returns I get a message “Server was unable to process your request”.

Any ideas at all?

CrmAuthenticationToken token = new CrmAuthenticationToken();
token.AuthenticationType = 0;
token.OrganizationName = “QSM”;

CrmService service = new CrmService();

service.Url = “http://qsmcrm:5555/qsm/mscrmservices/2007/CrmService.asmx”;
service.Credentials = new NetworkCredential(“administrator”, “pass@word1″, “crm”);

ICrmService s = new CrmWebService(service);
CrmQueryProvider p = new CrmQueryProvider(s);

var res = from c in p.Linq()
select c.fullname;
foreach (var i in res)
{
Response.Write(i);
}


Posted by
friism
27 May 2009 @ 12pm

Does the crmqueryprovider work if you don’t use linqtocrm? I.e. can you do a standard query? Otherwise I haven’t a clue.


Posted by
Brian
3 February 2010 @ 3pm

@brenden
Use the MetadataService, not CrmService
service.Url = “http://qsmcrm:5555/qsm/mscrmservices/2007/MetadataService.asmx”;


Posted by
Thomas
20 May 2010 @ 9am

Is there a chance to do something like paging?

I have to retrieve all contacts (about 500 000) and import them in a third party system using the webservice provided.

any idea?


Posted by
admin
20 May 2010 @ 9am


Leave a Comment