SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've just started to look at using spmetal with SP 2010 to read data from document libraries:

I'm curious as to how I can ensure that I only retrieve files from a sharepoint document library that have been published, there doesn't seem to be any facility in the code that spmetal generates to be specific about the data that it returns.

Would be interested to here if anyone has managed to achieve this.

all the best

share|improve this question
up vote 3 down vote accepted

I could be very wrong but from what I understand, SPMetal only generates code which replicates the structure of a list in the form of strongly typed objects - the generated code has no relevance on the contents of a list. (Please inform if incorrect).

To only retrieve published documents you need to read up on LINQ to SharePoint, to find out how to filter a query by specific columns and data, in your case find out what column is used to store whether a document is published and use that in your LINQ query.

share|improve this answer
We ended up referring to the enumeration for spfilelevel as a way to determine the currently published state of a given file. Hope this is of use.… – Anonymous Aug 27 '10 at 19:20

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.