Linq to CRM 0.2.0

Posted on | | 1 Comment on Linq to CRM 0.2.0

Got a new version of LinqtoCRM running, but it is not nearly as big an improvement as I had hoped. While Matt Warren’s posts proved a big boost, some of the stuff is not applicable to CRM (eg. constructing expression trees so they can be StringBuilded sequentially to SQL) and some of it I just have to think about some more.

Anyway, go get it while it’s hot.

Concise code

Posted on | | 1 Comment on Concise code

Yesterday when porting LinqtoCRM to VS 2008 Beta 2, I had to get an array of the types of the properties of some generic type. This array would be passed to Type.GetConstructor(). I had an array of PropertyInfos which contain the type of the property, and I could have new’ed up an array and looped the types into that. Instead I did this:

PropertyInfo[] props = typeof(T).GetProperties();
Type[] types = props.Select(p => p.PropertyType).ToArray();
ConstructorInfo cInf = typeof(T).GetConstructor(types);

Visual Studio/.Net changes in Beta 2

Posted on | | Leave a Comment on Visual Studio/.Net changes in Beta 2

A new beta of Visual Studio was released yesterday, you can read up on the general stuff at ScottGu’s Blog.
The release broke the various projects I’m working on in weird and wonderful ways, here are some of them:

  • The expression tree grammar has changed, some types have disappeared only for new ones to show up.
  • Anonymous types no longer have a zero-argument constructors (from the reflection API), but have to be initialized with their full complement of properties. The properties are read-only, even through the reflection API.
  • The old expression-tree visualizer doesn’t work with the new expression trees, get the new samples.
  • The IQueryable interface has been expanded to include an IQueryProvider-property. Depending on your implementation, you can get around this be returning this and implementing IQueryProvider in your IQueryable (as a side note, it would be great if someone could document the thinking behind the various interfaces floating around in System.Linq, even if it’s still subject to change).

I haven’t really pondered the deeper implications and/or motivations of these changes, merely dealt with them.

UPDATE: Matt Warren has written a coherent description of the IQueryable and associated interfaces, parts 1, 2, 3, 4 and 5.

Alpha version of LinqtoCRM released

Posted on | | Leave a Comment on Alpha version of LinqtoCRM released

I’ve uploaded an initial version of LinqtoCRM to CodePlex. It’s a proof-of-concept more than anything else, but it will handle some non-trivial queries (like joins). The goal of the project is to abstract away CRM’s (necessarily) clunky web service interface and unleash the amazing application platform underneath. While I’ve worked with Linq as part of my thesis for the last couple of months, I managed to throw this code together over the weekend. If you have good examples and a bit of compiler-knowledge, creating your own queryprovider is not overly hard.