How to get data from a caml results using caml - sharepoint

The scene is:
I've got items using caml on a list view(e.g. previewlist), and I'll have to query again from these items, is it possible using caml to query from SPListItemsCollection? as MSSQL we can do select * from(select * from tablename), but how can we finished that in caml ?
And if that impossible, i'll have to search from those items first and then add the result to a splist or a spview, anybody knows how to do this? (yeah, two diff ideas).

Maybe you can try using SourceQuery property, retrieve original query and build new one using operator to combine two queries?

Related

SharePoint 2010, CAML query to see if a new item has been added to a list (Announcements)

all. I am trying to build a CAML query for a SP2010 list that will check the Announcements to see if anything new has been added (or a CAML query + some functionality). I do not truly understand CAML and SP yet and would be grateful for any help - thank you.
Have a look around an SPQuery object if you want to go down the CAML route.
You will want to get all the items for a given date/time range unless you have a field that flags if an item is new..... the link below should help you build a query
http://social.msdn.microsoft.com/Forums/sharepoint/en-US/fed59f8e-72e2-46e2-9329-460fd65d7536/caml-query-datetime
Once you have a SPQuery object pass it to the SPList GetItems() method
You will then have a collection of items what you do with them then is all up to you :)
Hope this helps

Dynamically building CAML query in SharePoint 2010

I have an requirement of get the items from the list depends on the ItemID.I have list which contains 5000 items in which I retrieve only 1000 items for that I will dynamically build the CAML query using JohnHoliday CAML.NET and the query have 1000 conditions at that time I got Value does not fall within the Expected Range error. The query works fine upto 150 items but it throws error when the ItemID increases.Could you provide a suitable workaround for this issue ?
You're running into the size limit for CAML queries, which AFAIK isn't documented anywhere, but definitly exists.
If you only need to support 2010 then you can use the new <In> operator which probably with get you a bid further
In sharepoint 2010 there is a List view threshold configuration that give the administrator the ability to determine the maximum items you can retreive in a one patch
and to overcome this problem you can use
ContentIterator
check this link for more help
Why not iterate over SPList.Items and take which items you need? So there's no need to build a complex caml query. Or call SPList.GetItemByUniqueId.

Sharepoint search all columns of a list

I have a list in sharepoint. I want to search across all the columns for a term. How would you co about doing this?
My idea was to get the SPFieldCollection, get all the fields and generate the CAML on the fly then query the list to get the items. Just wondering if there was a better way to do this as generating the CAML may prove to be difficult.
If you don't like the idea of building the CAML using string concatenation, then you could consider using CAML.Net
I'm accessing SP with webservices, not Object Model. Anyway, I would create the CAML dynamically. Generating the CAML will not be difficult, as you can always tryout your logic with
U2U CAML Query Builder http://www.u2u.net/res/Tools/CamlQueryBuilder.aspx

CAML Query Help?

Is there a way to get all versions of list item(s) using a CAML Query?
I don't think that's exposed directly in any of the APIs that take CAML queries as parameters. You'll probably need to get the current version of the ListItem using your CAML query and then make another call to get all versions of that item.

CAML GroupBy usage when querying a list using the SPQuery or SPSiteDataQuery object

I'm not sure how to use the GroupBy clause when querying a list. The SPListItemCollection or datatable looks exactly the same regardless of the groupby clause.
SPQuery query = new SPQuery();
query.Query = "<GroupBy><FieldRef Name=\"Area\"/></GroupBy>";
DataTable result = list.GetItems(query).GetDataTable();
// result.Rows.Count = Same as ungrouped query
Is GroupBy only supported by Lists.asmx webservice?
Found a reference on MS Social which suggests it's not supported on the SPSiteDataQuery object http://social.msdn.microsoft.com/Forums/en-US/sharepointdevelopment/thread/ab8df6f5-35a0-401e-88cb-3eb31362bf0c/
I believe that clause is more related to how the grouping will be displayed in the UI. As far as the data returned goes, you might/should get some sorting but that's about it.
Regarding the UI, there is the GroupLimit element which limits how many groups are returned. There is also the Collapse element which has no meaning when used with SPQuery.
How were you hoping the data would be different?

Resources