Domanda

I connect sharepoint to sql server db. I made a list based on External Content Type. Because of amounth of data I had to add filter parameters during adding External Content Types Operations - on List. I add wildcard and limit filters with default values. I created list on External Content Type. I run default list web site. I didn't saw any data. So I edit web page and

        <Method Name="ExternalList">
            <Filter Name="Filter" Value="A*"/>
            <Filter Name="Limit" Value="50"/>
        </Method>

In that way it works.

I wrote in C# wpf application

            server.Lists client = new server.Lists();
            client.Url = string.Format("{0}/_vti_bin/Lists.asmx", FixUrl("http://server:port/sites/SiteCollecion/"));
            client.Credentials = System.Net.CredentialCache.DefaultCredentials;
         try
            {
                string xmlQueryContent = @"<Query xmlns=""http://schemas.microsoft.com/sharepoint/soap/""></Query>";
                XmlDocument docQuery = new XmlDocument();
                docQuery.LoadXml(xmlQueryContent.ToString());
                XmlNode QueryNode = docQuery.DocumentElement;

                string xmlQueryOptionsContent = @"<QueryOptions></QueryOptions>";
                XmlDocument docQueryOptions = new XmlDocument();
                docQueryOptions.LoadXml(xmlQueryOptionsContent.ToString());
                XmlNode QueryOptionsNode = docQueryOptions.DocumentElement;

                XmlNode clientsNode = client.GetListItems("ExternalList", null, QueryNode, null, null, null, null);
                DataSet clientsListsDataSet = new DataSet();
                XmlReader clientsReader = new XmlNodeReader(clientsNode);
                XmlReadMode oko = clientsListsDataSet.ReadXml(clientsReader);

                Console.WriteLine(clientsNode.InnerText);
                Console.WriteLine(clientsNode.InnerXml);
             }

I got 0 rows results. So the filters were not populated. Is it possible to set them up i C# application?

Connection works fine because I got results when I connect to not external list.

È stato utile?

Soluzione

You could try using the REST/oData web services to access the list items, features such as filter are part of the REST/oData protocol.

You can filter items and pagination directly from the url for example:

/Products?$filter=ID lt 4

OData sample on code project

http://www.codeproject.com/Articles/393623/OData-Services/

To access Rest/oData service in SharePoint 2010 use _vti_bin

/MySite/MySubSite/_vti_bin/listdata.svc/ExternalList

Here are some article and blogs on odata with windows application:

http://www.c-sharpcorner.com/UploadFile/54db21/insert-data-from-sharepoint-list-using-odata-service/

http://www.orbitone.com/en/blog/archive/2010/06/09/odata-and-wcf-data-services.aspx

If REST/odata is not turn automatically and you may need to install an small patch.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top