for insert / update / delete self operation, i can call BO.Save() that execute the DependencyDispose() to invalid cache in server and client-side.
example:
protected override void DataPortal_OnDataPortalInvokeComplete(DataPortalEventArgs e)
{
if (Csla.ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Server)
{
// Update operation (includes insert, update and delete self).
if (e.Operation == DataPortalOperations.Update || e.Operation == DataPortalOperations.Delete)
Caching.TaggingCacheDependency.DependencyDispose(Domain.TableNames.FriendLink);
}
protected Contructor()
{
Saved += (sender, e) => Caching.TaggingCacheDependency.DependencyDispose(Domain.TableNames.FriendLink);
}
but how to invalid cache for delete operation in server and client-side???
example:
public static bool DeleteFriendLink(System.String primaryKey)
{
var criteria = new SingleCriteriaWithResult< string, bool >(primaryKey);
DataPortal.Delete< FriendLink >(criteria);
return criteria.Result;
}
protected void DataPortal_Delete(object criteria)
{
if (criteria is SingleCriteriaWithResult< string, bool >)
{
var theCriteria = criteria as SingleCriteriaWithResult< string, bool >;
theCriteria.Result = _repository.Delete((theCriteria.Value)); // return true or false
}
}
Your existing code which invalidates cache on the server should be fine. For the client, you can override Save and after base.Save returns, you can invalidate your cache there.
Andy
If your client is making an async data portal call, you'd do the client-side invalidation in the factory method, in the callback handler. Like this:
var dp = new DataPortal<CodeList>();
dp.FetchCompleted += (o, e) =>
{
CodeList.ClearCache();
callback(o, e);
};
dp.BeginFetch();
Copyright (c) Marimer LLC