views:

482

answers:

1

Hello. I am trying to implement functionality on my client side Domain Context where I want to work with each of the database records before they are sent to the client. To create a simple illustration lets assume I wanted to change a field on my customer table called LastAccessed and set it with the current DateTime. Here is what I tried in my Domain Service Class:

    public IQueryable<Customer> GetCustomers()
    {            
        foreach (Customer c in this.DataContext.Customers)
        {
            c.LastAccessed = DateTime.Now;
        }
        DataContext.SubmitChanges();

        return this.DataContext.Customers;
    }

This sort of works because it does update the LastAccessed date before the record is returned to the client but it updates ALL Customer records not just the one the client is requesting. In my client side silverlight application I am applying a query but when using runtime debugging I can see it is updating every customers however because I am using a query only the client side only the requested customer(s) are returned and pushed over the wire.

If I watch my database with SQL profiler I can see that it is in fact requesting all records and then it is requesting only the queried records. So where would I intercept those records being returned and update only their LastAccessed times.

So in a nutshell I need to find a way to access only the records that will be ultimately returned and at this point in the code I seem to have the entire table. I know I can pass in a specific Customer ID and query that and then work with those results but I want the flexibility for the query to come from the client so that if they are populating a grid based on some search criteria like " State == 'NY' " all the records that are returned to populate the grid results cause the LastAccessed field to update. Any help would be appreciated! Thank You!

A: 

I finally got an answer over at the Silverlight Forum you can find the response I got here:

Silverlight Forum

LarryDev