日期:2014-05-20  浏览次数:20785 次

用linq查询得到的Var 变量查找指定索引的元素报错 求指点问题在哪里?
                        var q = from c in db.out_call where c.result != 1 && c.isAuto == 0 && c.outcallCount < c.outCallMaxCount select c;
                        if (q != null && q.Count() > 0)
                        {

                            for (int a = 1; a < q.Count(); a++)
                            {
                                anologCh = 1;
                                for (int i = 0; i < nMaxCH; i++)
                                {
                                    if (ShDll.SsmGetChType(i) == 0 && ShDll.SsmGetChState(i) == 0 && SsmGetLineVoltage(i) > 10)
                                    {
                                        anologCh = i;
                                        break;
                                    }

                                }
                                if (anologCh == -1)
                                    continue;
                                phone=q.ElementAt(a).phoneNum .ToString().Trim();

phone=q.ElementAt(a).phoneNum .ToString().Trim();
这一行会出错错误是
LINQ to Entities 不识别方法“SoundStudyTest0010.out_call ElementAt[out_call](System.Linq.IQueryable`1[SoundStudyTest0010.out_call], Int32)”,因此该方法无法转换为存储表达式。
 求教怎么解决? 
------解决方案--------------------
var q=....
q=q.ToList(); 
。。。。。