SharePoint 2010 – Adding Created, CreatedBy, Modified and ModifiedBy to SPMetal’s Generated Classes

By default, SPMetal doesn’t map the Created, Created By, Modified and Modified By fields to it’s generated objects. To remind SPMetal they exist you can easily add them to your parameters XML file (using /parameters:myfile.xml at command line). Of course. You can selectively add where you need it, or add it to Item:

<Column Name="Editor" Member="CreatedBy" />
<Column Name="Author" Member="ModifiedBy" />
<Column Name="Created" />
<Column Name="Modified" />

Also, here’s a template of the SPMetal command:

"%programfiles%\Common Files\Microsoft Shared\Web Server Extensions\14\BIN\spmetal.exe" "/web:http://myserver/someweb/foo" /language:csharp /code:SPFoo.cs /serialization:unidirectional /parameters:FooSPMetalParameters.xml

See also:


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.