0

I'm trying to return the list item ID (s.ID), and the ID of a lookup column (s.VendorID). I get the following error:

The query uses unsupported elements, such as references to more than one list, or the projection of a complete entity by using EntityRef/EntitySet.

Is this error because s.VendorID is from a lookup column? (Edit: This does seem to be related to the lookup column. I can return data from more than one non-lookup column in the table. However, I need the lookup column so that adding list items works for end users.)

How can I get this to work? Code examples appreciated.

using (SPLinqDataContext dc = new SPLinqDataContext(SPContext.Current.Web.Url))
{
    {
        EntityList<VendorSearchesItem> vendorSearches = dc.GetList<VendorSearchesItem>("Vendor Searches");

        var vendorSearchesQuery = from s in vendorSearches
                                  select new
                                  {
                                      s.Id,
                                      s.VendorID //lookup column
                                  };

        spGridView.DataSource = vendorSearchesQuery; 
        spGridView.DataBind();
    }
}
0

Changed

s.VendorID //lookup column

to

s.VendorID.Id

which worked. Used the dot operator.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.