C #: 'IEnumerable <Student>' does not contain a definition for 'Intersect'

I wrote one line of code a long time ago, so please be patient if I ask a dumb question.

Although IntelliSense shows the Intersect method after the names, I get the following error when trying to compare two IEnumerables.

I am trying to compare the result of a database query against an ordered list in html.

'IEnumerable' does not contain a definition for 'Intersect' and the best overload method 'Queryable.Intersect (IQueryable, IEnumerable)' requires a receiver of type '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() && Names.Intersect(OrderedList).Count() == OrderedList.Count()) // The error is shown here.
        { IsMatch = true; }

I wonder what I'm doing wrong. Any help would be appreciated. Thank.

At the end, the code is as follows:

    IEnumerable<string> Names = GetData(CardNumber, Section).Select(s => s.FullName);
    IEnumerable<string> OrderedList = driver.FindElements(By.XPath("//li[@ng-repeat='Names']")).Select(i => i.Text);

Thank you very much for your help.

+4
1

, Intersect , . Student IWebElement.

Intersect , , .

, (, IEnumerable<string>):

var studentNames = Names.Select(student => student.Name);
var webElementNames = OrderedList.Select(webElement => webElement.Name);

All :

if(Names.All(student => OrderedList.Any(webElement => webElement.Name == student.Name)))

, , , .

+5

Source: https://habr.com/ru/post/1663382/


All Articles