小编fra*_*ein的帖子

C#:'IEnumerable <Student>'不包含'Intersect'的定义

我写了一行代码已经很久了,所以,如果我问一个愚蠢的问题,请耐心等待.

尽管IntelliSense在Names之后显示了Intersect方法,但在尝试比较两个IEnumerables时出现以下错误.

我试图比较数据库查询的结果与html中的有序列表.

'IEnumerable'不包含'Intersect'的定义,并且最好的扩展方法重载'Queryable.Intersect(IQueryable,IEnumerable)'需要'IQueryable'类型的接收器

namespace Data.Repositories
{
    public class StudentsRepository
    {
        public class Student
        { 
            public string FullName { get; set; }
        }

        public static IEnumerable<Student> GetData(string CardNumber, string Section)
        {
            // FullName varchar(300) in Database
            return CommonFunctions.ExecuteReader1<Student>(QryStudentSectionDetails(CardNumber, Section)).AsQueryable();
        }
    }
}


namespace Tests.ActionsLibrary.StudentPaper
{
    public class StudentActions:TestBase
    {
        bool IsMatch = false;

        // Get Names from DataBase
        IEnumerable<Student> Names = GetData(CardNumber, Section);

        // Get Names from Ordered list in HTML
        IEnumerable<IWebElement> OrderedList = driver.FindElements(By.XPath("//li[@ng-repeat='Names']"));

        if (Names.Count() == OrderedList.Count() && …
Run Code Online (Sandbox Code Playgroud)

c# linq ienumerable generic-collections

9
推荐指数
1
解决办法
5783
查看次数

标签 统计

c# ×1

generic-collections ×1

ienumerable ×1

linq ×1