April 6, 2010

Xtensive.Practices, ASP.NET helpers

So I'm thinking about the following set of helpers to implement for regular ASP.NET:

1) SessionManager from Xtensive.Storage.Web.

If you don't know, this is an IHttpModule automatically providing Session for each web request. More details are described here.

But to consider this part completed, it must be extended to automatically attach a DisconnectedState to Session provided by it for a particular web request. This feature might be quite useful for long-running transaction scenarios - e.g. wizards, where actual database modification must be performed only on the final step, although the data is updated during all the steps there.

I'm thinking about the following syntax:
  • TData SessionManager.Demand().GetDisconnected<TData>(string key = null) where TData : class will attach cached DisconnectedState and deserialize cached data (of TData type) after doing this. If result of this call isn't null, it will be serialized & placed back to cache on successful completion of transaction.
  • SessionManager.Demand().SetDisconnected<TData>(string key = null, TData value) where TData : class will set the specified value. If null, the cached one will be removed.
2) Validator control (of course, server-side only) that automatically validates version of a particular object (i.e. performs an optimistic version check).

Not sure to which control these validators must be attached - probably, they must be attachable only to our special invisible controls identifying the object.

Any ideas are welcome here.

3) Paging helpers.

Actually I'm absolutely not sure if this is necessary at all - there are plenty of paging examples for LINQ like this and that, and any of them must work.

So may be we must just add something like IQueryable<T>.Page(int pageSize, int pageIndex = 0) extension method with its LINQ translator forwarding it to .Skip(...).Take(...) sequence? But AFAIK all the grids for ASP.NET that support LINQ are capable of adding this sequence automatically.

Thus... May be we must just show a sample here? Again, any ideas are welcome.

Please leave your opinions and requests in comments. The similar post for ASP.NET MVC will appear shortly.