Pages

Jun 10, 2011

SPLINQ - Parameter.xml to show hidden fields

Problem:  I can never remember the syntax for the parameters files and need to lookup how to include hidden SP 2010 fields in the LINQ to SharePoint Proxy.

Initial Hypothesis:  Use a Parameters.xml file to get SPMetal to generate the proxy with hidden fields.  You can use the IncludeHiddenColumns element within the ContentType element to include all hidden fields or as I have done in the resolution example, specify the fields to include using the element Column.

Resolution:

1.> Create a parameters.xml (name it for you specific project) and add it to the 14\bin directory.

2.> Use the dos cmd prompt to generate the LINQ to SharePoint Proxy.

3.> Add the generate LINQ to SharePoint proxy code to your Visual Studio project. 

4.> Add the query to show 1 of the hidden fields that is now part of your proxy.

More Info: You can use the same technique for custom site columns however, you will need to manually edit the proxy to perform the appropriate casting.  I would still use the iCustomMapping interface for custom site columns.

No comments: