This question is locked. New answers and comments are not allowed.
Hey guys,
I'm using Oracle as a backend and trying to call Count(), passing in a predicate, but am getting an incorrect result. It basically returns the total number of rows in my table regardless of the query passed in as the predicate. Here some code...
Bringing the data in memory to count total records is not an option because I am dealing with a table of more than 30M records.
Is there an issue with Count() in general, or with Oracle in particular?
Thanks, and regards,
Kevin Babcock
I'm using Oracle as a backend and trying to call Count(), passing in a predicate, but am getting an incorrect result. It basically returns the total number of rows in my table regardless of the query passed in as the predicate. Here some code...
// When trying with parameters passed to the method, | |
// I get the TOTAL number of Customers | |
var database = Database.Get("ConnectionString"); | |
var dataContext = database.GetObjectScope(); | |
var records = dataContext.Extent<Customer>().AsQueryable<Customer>(); | |
var count = records.Count(c => c.City == city && c.Country == country); | |
// When trying with hard-coded values, | |
// I still get the TOTAL number of Customers | |
var database = Database.Get("ConnectionString"); | |
var dataContext = database.GetObjectScope(); | |
var records = dataContext.Extent<Customer>().AsQueryable<Customer>(); | |
var count = records.Count(c => c.City == "Fairfax" && c.Country == "USA"); | |
// When bringing the results in memory (and not using a predicate), Count() returns the | |
// correct number of Customers | |
var database = Database.Get("ConnectionString"); | |
var dataContext = database.GetObjectScope(); | |
var records = dataContext.Extent<Customer>().AsQueryable<Customer>(); | |
var customers = records.Where(c => c.City == "Fairfax" && c.Country == "USA").ToList<Customer>(); | |
var count = customers .Count(); |
Bringing the data in memory to count total records is not an option because I am dealing with a table of more than 30M records.
Is there an issue with Count() in general, or with Oracle in particular?
Thanks, and regards,
Kevin Babcock