Take the 2-minute tour ×

I need data from 2 different databases I have try following

var User = (from U in _db.TblUsers
                        where U.IsAdmin == false
                        select U).ToList();

var AspNewsUser = (from A in _dbAspNet.aspnet_Users                        
                   select A).ToList();

var result = (from U in User
              join A in AspNewsUser
              on U.UserID equals A.UserId
              select U);

But I get the following error message

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

share|improve this question
Is UserId nullable? –  2kay Nov 25 '12 at 6:58
No it's Not Nullable. –  B JP Nov 25 '12 at 7:00
In both collections UserId has different types. Check this first. –  Kundan Singh Chouhan Nov 25 '12 at 7:09

2 Answers 2

up vote 1 down vote accepted

As you can see in the table schema of aspnet_Users, Userid is a uniqueidentifier (maps to GUID in entity framework). I bet that TblUsers.UserID has a different type (like int).

share|improve this answer

Use projection, make them the same anonymous type.

    var Users = (from U in _db.TblUsers
                    where U.IsAdmin == false
                    select new { UserID = U.UserID }).ToList();

    var AspNewsUsers = (from A in _dbAspNet.aspnet_Users                        
                    select new { UserID = A.UserID }).ToList();

    var result = (from i in Users join o in AspNewUsers on i.UserID equals o.UserID).ToList();
share|improve this answer
Concat != Join. –  usr Nov 25 '12 at 11:12

Your Answer


