長い間、1行のコードしか書いていないので、私は愚かな質問をしています。C#: 'IEnumerable <Student>'に 'Intersect'の定義が含まれていません
IntelliSenseがNamesの後にIntersectメソッドを表示しても、2つのIEnumerablesを比較しようとすると次のエラーが発生します。
データベースクエリの結果とhtmlの順序付きリストを比較しようとしています。 '交差' の定義との最良拡張メソッドオーバーロード 'Queryable.Intersect(のIQueryable、IEnumerableを ')を含んでいない
の受信機を必要とします'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() && Names.Intersect(OrderedList).Count() == OrderedList.Count()) // The error is shown here.
{ IsMatch = true; }
私は何が間違っているのだろうか。どんな助けでも大歓迎です。ありがとう。
コードは次のようになります終わり:
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);
あなたの助けをありがとうございました。
「Students」と「IWebElements」の間でどのように交差すると思いますか?あなたはそれの上に別の問題を抱えているかもしれませんが、それは確かにあなたが世話しなければならないものです。 – SimpleVar