How does an IQueryable whose Linq returns an anonymous type get its number of records?

the following Linq query returns IQueryable of anonymous type:

var users2 = from u1 in Users
             join u2 in distribs on u1.pDistribId equals u2.Id
             into temp
             from u3 in temp.DefaultIfEmpty()
             select new {
                 u1.Id,
                 u1.UserName,
                 u1.pDistribId,
                 pUserName = u3 == null ? "" : u3.UserName,
                 u1.Phone,
                 u1.Name,
                 u1.pCustomUser,
                 u1.CoName,
                 u1.CoPhone,
                 u1.Birthday,
                 u1.QQ,
                 u1.Email,
                 u1.SelfIntr
             };

if you want to get the number of records of users2, use the following method to get the number of records

var c = users2.Count();

will prompt an error:

DbComparisonExpression requires parameters of comparable types.

Debug view as follows:

how does an IQueryable type like this anonymous type get its number of records?


try ToList () first and then call the method to get the quantity.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b37b35-2c0e2.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b37b35-2c0e2.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?