Tuesday, July 28, 2009

C#3 anonymous types, parameters and LINQ for XML

Crash learning to work with LINQ XML (see sample code below to get a distinct list from an XML file written by a reporting services report) re-introduced me to a really usefull feature of C#3 called anonymous types where you can create an object on the fly. You can then use that object in the same method, however if you wish to pass it to another method then things start getting complicated. This blog note Anthony Steele's Blog : C#3 anonymous types as parameters points you in the right direction to whats possible.

(He also mentions a very good book on C#3 (by Bill Wagner) to hone your skills)

Note: as a learning LINQ is a lot of trial and error you can test your LINQ code in a very helpful utility called:http://www.linqpad.net/

Sample LINQ code
XDocument xDoc = XDocument.Load(@"c:\temp\RSD.xml");
var q = (from e1 in xDoc.Descendants("{SchemaName}Detail").Distinct()
let div = e1.Attribute("Division").Value
let cc = e1.Attribute("CostCode").Value
select new { div, cc }).Distinct();

q.Dump(); //this shows you the contents of q

Monday, July 13, 2009

Integrating External Document Repositories with SharePoint Server 2007

Whilist loading documents into Sharepoint from existing file shares is a good option it is often time consuming and here is an interesting article showing how you can link existing exteral document libraries with sharepoint Integrating External Document Repositories with SharePoint Server 2007:

Saving Reports to SharePoint using WebDav from Windows 2008

I was having difficulty getting Enterprise Reporting Services to run a data subscription (running on Windows 2008) to save reports into a Sharepoint Document library using a URL.

I found that Windows 2008 does not install the required WebDav Client (Not to be confused with the additional IIS7 WebDav Server addon) .

You can install this client by Adding the "Desktop Experience Feature" on Windows 2008, however this also installs lots of other things that you probably dont want and Ive not found a way to only install WebDav Client support.

After a server re-boot it works well and talks to Sharepoint Document Libraries, My thanks to the following article for assistance. Browsing SharePoint using WebDav from Windows 2008 « In The Mix