locked
Contains() on a SharePoint list RRS feed

  • Question

  • I've got a SharePoint list added as a datasource in LS 2012.  I've got a subquery on the list:

    Dim countries As New List(Of String)            
    countries.Add("United States")
    query = From q In query
            Where countries.Contains(q.Country)
            Select q

    This is the query code, and it should return items where the Country is in the list of countries I specified (I've added "United States" as an example).

    However, when I run it, I get an error:

    The expression value(System.Collections.Generic.List`1[System.String]).Contains([10007].Country) is not supported.

    What gives?  I thought we could use Contains in the query code in LightSwitch?  Is it because it's a SharePoint list?


    Free Visual Studio LightSwitch extensions: Elyl's Extensions


    • Edited by ElylV Thursday, March 13, 2014 5:02 PM
    Thursday, March 13, 2014 5:00 PM

All replies

  • Not sure, but maybe try this:

    Dim countries As New List(Of String)            
    countries.Add("United States")
    query = query.Where(Function(q) countries.Contains(q.Country))

    HTH,

    Josh


    • Edited by joshbooker Monday, March 17, 2014 3:32 PM
    Monday, March 17, 2014 3:31 PM
  • Yeah, I've tried every combination of Where I can find, in LINQ and as a function.  It seems like SharePoint doesn't allow querying of the data in its lists using anything complex (like .Contains)

    Has anyone else ever got this to work in SharePoint?  It works on other datasources, just not the SharePoint.


    Free Visual Studio LightSwitch extensions: Elyl's Extensions

    Monday, March 17, 2014 3:34 PM