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, 2013 at 22:31
  • There is no solutions !! why :( :(
    – NOOR
    Apr 20, 2013 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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