Hi Ian
(I'm from Herfordshire too!)
For the simple fetches, why not have a couple of generic helper methods, say one for retrieving a single entity and one for a collection. You can do just about everything with the predicates, prefetch paths and ExcludeIncludeFieldsLists.
I got a bit tired of our old pre-LLCoolJ service-based write-a-new-method-and-wrappers-for-everything architecture, so I wrote an IDirectDataService with a few simple methods like this:-
EntityCollection<T> FetchCollection<T>(string processName, IPredicate filterToUse) where T: EntityBase2;
EntityCollection<T> FetchCollection<T>(string processName, CollectionFetchParameters parameters) where T: EntityBase2;
Now the client side can fetch anything it likes and I don't have to change any interfaces!
Here is an example of the server side:
public EntityCollection<T> FetchCollection<T>(string processName, CollectionFetchParameters parameters) where T: EntityBase2
{
Guard.NotNull(processName, "processName");
Guard.NotNull(parameters, "parameters");
var result = new EntityCollection<T>();
using(var scope = new TransactionScopeWrapper("DirectDataService:" + processName))
{
var existingTimeout = scope.DataAccessAdapter.CommandTimeOut;
if (parameters.CommandTimeOut != null)
{
scope.DataAccessAdapter.CommandTimeOut = parameters.CommandTimeOut.Value;
}
scope.DataAccessAdapter.FetchEntityCollection(result, parameters.FilterBucket, parameters.MaxNumberOfItemsToReturn,
parameters.SortExpression, parameters.PrefetchPath,
parameters.ExcludeIncludeFieldsList, parameters.PageNumber, parameters.PageSize);
if (parameters.CommandTimeOut != null)
{
scope.DataAccessAdapter.CommandTimeOut = existingTimeout;
}
scope.Complete();
}
return result;
}
Cheers
Simon