2

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.

1

2 Answers 2

3

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

1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.