Lets say I have these three methods:
public Customer GetCustomerByCustomerGuid(Guid customerGuid)
{
return GetCustomers().FirstOrDefault(c => c.CustomerGuid.Equals(customerGuid));
}
public Customer GetCustomerByEmailAddress(string emailAddress)
{
return GetCustomers().FirstOrDefault(c => c.EmailAddress.Equals(emailAddress, StringComparison.OrdinalIgnoreCase));
}
public IEnumerable<Customer> GetCustomers()
{
return from r in _customerRepository.Table select r;
}
//_customerRepository.Table is this:
public IQueryable<T> Table
{
get { return Entities; }
}
Would this cause a query to the database each time I make a call to GetCustomerByEmailAddress()
/ GetCustomerByCustomerGuid()
or would EF cache the results of GetCustomer()
and query that for my information?
On the other hand, would it just cache the result of each call to GetCustomerByEmailAddress()
/ GetCustomerByCustomerGuid()
I am trying to establish the level of manual caching I should go to, I really dislike running more SQL queries than are absolutely necessary.