So, I looked around for a while to answer my problem, and I see to add using System.Linq, except that I already have this, so I donβt know that my code does not compile. There is code in my context _accountreader, so why does it say that the definition of this does not exist?
The line return _accountReader.Where(x => x.Age);is where the compiler yells at me.
public interface IAccountReader
{
IEnumerable<Account> GetAccountFrom(string file);
}
public class XmlFileAccountReader : IAccountReader
{
public IEnumerable<Account> GetAccountFrom(string file)
{
var accounts = new List<Account>();
return accounts;
}
}
public class AccountProcessor
{
private readonly IAccountReader _accountReader;
public AccountProcessor(IAccountReader accountReader)
{
_accountReader = accountReader;
}
public IEnumerable<Account> GetAccountFrom(string file)
{
return _accountReader.Where(x => x.Age);
}
}
public class Account
{
public int Age { get; set; }
}
source
share