Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I wanna join two list and fill drop down list by specific column but i have error in join query note:c.user_id is lookup field

my code

lst.DataSource = (from c in dc.Complainant
                     join u in dc.User_collec
                     on c.User_id equals u.User_id
                     select new { m=u.Title }).ToList();

the Error is The type of one of the expressions in the join clause is incorrect. Type inference failed in the call to 'Join'.

I think the solution is easy but i need it :( –  NOOR Apr 20 '13 at 22:31
There is no solutions !! why :( :( –  NOOR Apr 20 '13 at 23:19

1 Answer 1

If your lookup is not of multi type, something like this is worth a shot:

lst.DataSource = (from SPListItem c in dc.Complainant
    where c["User_id"] != null
    join SPListItem u in dc.User_collec
    on new SPFieldLookupValue(c["User_id"] as string).LookupValue
    equals u.User_id
    select new { m=u.Title }).ToList();

The differens is mainly the extraction of the value from the Lookup column, and that it takes in account cases where the c.User_id is null


This site is currently not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .