如何在Linq c#中获得多个结果集?

时间:2016-11-02 06:23:33

标签: c# asp.net linq

var compobj = (from a in _db.FO_BA where a.BACode == vbacode select a);
foreach (var a in compobj)
{
    companycode = a.CompanyCode.ToString();
}
var emailobj = (from b in _db.EmailSentError where b.CompanyCode == companycode select b);
foreach(var b in emailobj)
{
    emails = b.Emails.ToString();
}

emailobj返回null,如何获得多个结果集?

谢谢,

2 个答案:

答案 0 :(得分:1)

var companycodeList= _db.FO_BA.Where(a=>a.BACode == vbacode)
                              .Select(x=>x.CompanyCode.ToString()).ToList();
var emailsList = _db.EmailSentError.Where(x=>companycodeList.Contains(x.CompanyCode))
                    .Select(y=>y.Emails.ToString()).ToList();

答案 1 :(得分:0)

如果您想获得多个电子邮件字符串,那么您可以尝试加入LINQ

Traceback (most recent call last):
  File "C:/Users/Imran/PycharmProjects/webscrapping/WF Item.py", line 6, in <module>
    driver = webdriver.Chrome('C:\\Users\\Imran\\AppData\\Local\\Programs\\Python\\Python36\\selenium\\chromedriver.exe')
  File "C:\Users\Imran\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 69, in __init__
    desired_capabilities=desired_capabilities)
  File "C:\Users\Imran\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 92, in __init__
    self.start_session(desired_capabilities, browser_profile)
  File "C:\Users\Imran\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 179, in start_session
    response = self.execute(Command.NEW_SESSION, capabilities)
  File "C:\Users\Imran\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 236, in execute
    self.error_handler.check_response(response)
  File "C:\Users\Imran\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 192, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: session not created exception
from unknown error: Runtime.executionContextCreated has invalid 'context': {"auxData":{"frameId":"27028.1","isDefault":true},"id":1,"name":"","origin":"://"}
  (Session info: chrome=54.0.2840.71)
  (Driver info: chromedriver=2.23.409699 (49b0fa931cda1caad0ae15b7d1b68004acd05129),platform=Windows NT 6.3.9600 x86_64)