Tuesday, September 25, 2012

Query XML using LINQ

Share/Save/Bookmark


I have a scenario, to calculate the size of the documents in library.
Now after i read the library using web service in to xml (soap) i do not want to iterate or loop
all items to read the value in the column,file size. I was wondering if i can apply a aggregate function(sum)
like we have in SQL. Here is how i did with XDocument by applying LINQ on XML

XDocument xDoc = XDocument.Load("test.xml");
// Incase if source is a XmlNode
//Xdocument.Parse(XmlNode.OuterXml);
//namespace is always necesary for xdoc to identify the elements
XNamespace z = "#RowsetSchema";
var size = (from item in xDoc.Descendants(z + "row")
             select Convert.ToDouble(item.Attribute("ows_File_x0020_Size").Value.Substring(item.Attribute("ows_File_x0020_Size").Value.IndexOf('#') + 1))).Sum();

XDocument.Descendants("z:row") will always throw exception that semicolon is not allowed.
Thats one more reason why namespace should be passed.



Subscribe

Sunday, September 9, 2012

component version is not compatible with the search database

Share/Save/Bookmark

One of the reason for causing the below error is due to missing database upgrade in the server for search service application.

ERROR :The synchronization operation of the search component: 8bce98fb-8409-491d-877e-143590c9f055 associated to the search application: Search Service Application on server: has failed. The component version is not compatible with the search database: Search_Service_Application_CrawlStoreDB_4925b8b4b5574940ba8389bffd59423f on server: . The possible cause for this failure is The database schema version is less than the minimum backwards compatibility schema version that is supported for this component. To resolve this problem upgrade this database..


In order to update the SharePoint databases, you must manually run the PSconfig utility. To run the utility:
Check if the server needs update with the following command in the sharepoint powershell admin,

(get-spserver $env:computername).NeedsUpgrade

If it returns TRUE, then follow the steps below

1.Open an Administrative command prompt.

2.Change directory to C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\BIN

3.Run PSConfig.exe -cmd upgrade -inplace b2b -force -cmd applicationcontent -install -cmd installfeatures

This will take couple of minutes to finish.


Subscribe