public interface IBusinessFetcherService<TItem>
{
TItem? Fetch();
Task<TItem> FetchAsync();
}
Sync version returns nullable while async does not
You most likely don't need sync version
If everything is async then Async suffix is redundant
If it can return null then Try... naming convention gives a little hint
So you probably should end with:
public interface IBusinessFetcherService<TItem>
{
Task<TItem?> TryFetch();
}
But now the question is about what it does?
Does it retrieve a single entity? Collection?
This interface is very generic (having TItem on it and single method, it it just Func<T?>, isn't it?) while usage sounds very specific (a class to retrieve singletons?).
I don't know enough what is is going to happen but generic repositories are very last lockdown ;-)
https://github.com/Inerska/ULApi/blob/993be777c64c525fec4eeb6d931858e3e41dbb44/src/ULApi.BusinessLayer/IBusinessFetcherService.cs#L23
Just on conventions:
Async
suffix is redundantnull
thenTry...
naming convention gives a little hintSo you probably should end with:
But now the question is about what it does? Does it retrieve a single entity? Collection? This interface is very generic (having
TItem
on it and single method, it it justFunc<T?>
, isn't it?) while usage sounds very specific (a class to retrieve singletons?). I don't know enough what is is going to happen but generic repositories are very last lockdown ;-)