Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Is it possible to with the Object Model query several lists at the same time and get the result merged together? Something like linked sources in SharePoint Designer?

I have created a web part that lists events from a calendar but I want to be able to lists events from several calendars. I know that I can query from different lists and then sort the result myself but this dose not feel optimal.

The best thing would be if I could create the source from SharePoint designer or from SharePoint then add my webpart and then send the "linked source" to my webpart that then would see the data as if it is one list.

share|improve this question
    
Similar question can be found at sharepointoverflow.com/questions/1102/… –  Jaap Vossers Mar 12 '10 at 16:08
add comment

2 Answers

Are you using MOSS or WSS only?

If you have MOSS, have you tried the Content Query Web Part?

If you really need to use the object model, you could try the SPSiteDataQuery class

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spsitedataquery.aspx

share|improve this answer
add comment

The linked data source in SharePoint Designer uses the AggregateDataSource class.

AggregateDataSource.Sources

The above is a collection of DataSource objects.

AggregateDataSource.Aggregate

This is a string similar to this:

<concat name="data source">
    <datasource name="Calendar" id="1" Type="SPList"/>
    <datasource name="Calendar2" id="0" Type="SPList"/>
</concat>

Using several SPDataSources in the .Sources collection that relate to your calendar lists and an appropriate .Aggregate string should result in the data you want.

share|improve this answer
add comment

Your Answer

 
discard

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