How to use where in data set to filter result

1

I have a data set that is called from a web service. What I'm trying to do is call this web service by filtering the type of project I want to get.

This means that I do not want to call projects that have a DefinitionType "Survey".

I have tried to do it several times but it does not work for me, any suggestions?

Here is the structure of the data set:

<xs:element name="Table">
<xs:complexType>
  <xs:sequence>
     <xs:element name="ProjectID" type="xs:string" minOccurs="0"/>
     <xs:element name="Title" type="xs:string" minOccurs="0"/>
     <xs:element name="Description" type="xs:string" minOccurs="0"/>
     <xs:element name="Language" type="xs:string" minOccurs="0"/>
     <xs:element name="Category" type="xs:string" minOccurs="0"/>
     <xs:element name="Subcategory" type="xs:string" minOccurs="0"/>
     <xs:element name="CategoryID" type="xs:long" minOccurs="0"/>
     <xs:element name="SubcategoryID" type="xs:long" minOccurs="0"/>
     <xs:element name="StartDate" type="xs:dateTime" minOccurs="0"/>
     <xs:element name="EndDate" type="xs:dateTime" minOccurs="0"/>
     <xs:element name="Private" type="xs:string" minOccurs="0"/>
     <xs:element name="Archived" type="xs:string" minOccurs="0"/>
     <xs:element name="BaseLanguage" type="xs:string" minOccurs="0"/>
     <xs:element name="Confidential" type="xs:string" minOccurs="0"/>
     <xs:element name="Status" type="xs:string" minOccurs="0"/>
     <xs:element name="DefinitionType" type="xs:string" minOccurs="0"/>
  </xs:sequence>
</xs:complexType>
</xs:element>

Here is my code which I try to filter where I put the where I get the following message:

  

(Possible unintended reference comparisons; to get to value comparisons, cast the left hand side to type 'string').

Which I have tried to do, but without result:

string projectId = proj.ProjectID.ToString();
var projectType = client.GetProjectDetails(ref apiKey, ref message, languages);
var type = projectType.Tables["Table"].Select("ProjectId = '" + projectId + "'")
    .Select(r => r["DefinitionType"])
    .Where(s => s != "survey") //aqui me aparece el mensaje mencionado.
    .Select(s => s.ToString())       
    .FirstOrDefault();
    
asked by A arancibia 10.03.2016 в 17:44
source

1 answer

0

To use a dataset with linq you need this to be AsEnumerable()

Sample query syntax examples: projection (LINQ to DataSet )

DataTable dt = projectType.Tables["Table"];

var type = dt.AsEnumerable().
            .Where(s => s.Field<string>("DefinitionType") != "survey") 
            .FirstOrDefault();

What I do not understand is because you define so much Select()

    
answered by 10.03.2016 / 17:56
source