I am using Subsonic (SimpleRepository) to query my SQL 2008 database. I am trying to write a query that will calculate the number of days between two fields and return records where the difference is less than a given number. However, I get a "The member 'Days' is not supported" error.
Can anybody suggest an alternative query?
Here's the query I'm trying to run:
var repository = new SimpleRepository("MyConnection",
SimpleRepositoryOptions.None);
var query = (from c in repository.All<Data.Customer>()
where c.LastSynchronizedOn == null ||
(c.LastSynchronizedOn - c.CreatedOn).Days <= 7)
select c).Distinct();
EDIT:
I tried:
(c.LastSynchronizedOn == null || (c.LastSynchronizedOn.Value - c.CreatedOn).Days <= 7)
I get the same exception: The member 'Days' is not supported
I also tried:
(c.LastSynchronizedOn == null || ((c.LastSynchronizedOn - c.CreatedOn) > new TimeSpan(7, 0, 0, 0)))
I get: Failed to convert parameter value from a TimeSpan to a String.