To avoid disabling caching, use a temporary variable, so the query will
still be cached and the value passed as external parameter:
           while (true) {
var now=DateTime.Now;
               var customers = from customer in customerTable
                               where customer.Inserted < now
                               select customer;

               foreach (var customer in customers) {
                  Console.WriteLine(customer.Id + " " +
customer.Username);
               }
               Thread.Sleep(3000);
          }

On Tue, Apr 21, 2009 at 15:41, <[email protected]> wrote:

>
>
>
> On Apr 21, 2:27 pm, Giacomo Tesio <[email protected]> wrote:
> > In a SQL transaction such behaviour would be right.
> >
> > But, this is probably a bug. How Linq to Sql work on such a query?
>
> Hi Giacomo,
>
> If DateTime.Now is in the query then it should be evaluated everytime
> the query is executed. For example the first time it would be:
>
> select * from customers where inserted < '22 Apr 2009 14:40:39'
>
> calling the same query 3 seconds later should generate:
>
> select * from customers where inserted < '22 Apr 2009 14:40:42'
>
> Whereas at the moment the second call generates the same SQL as the
> first call.
>
> I can get DBLinq to work properly for this query by stopping it from
> caching query expressions in QueryBuilder.cs but this will obviously
> create a lot of extra work for other queries that do not change on
> each call:
>
>        protected virtual void SetInSelectCache(ExpressionChain
> expressions, SelectQuery sqlSelectQuery)
>        {
>            //var cache = QueryCache;
>            //lock (cache)
>            //    cache.SetInSelectCache(expressions, sqlSelectQuery);
>         }
>
> Regards,
>
> Greyman.
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"DbLinq" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/dblinq?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to