No, this is nothing special. You can write:
public static ResourceItem GetById(int id)
{
WithDataContext(db =>
{
});
}
private static T WithDataContext<T>(Func<TestDataContext, T> function)
{
using (var db = DataContextFactory.Create<TestDataContext>())
{
return function(db);
}
}
I am not sure if this would be particularly helpful.
(Note that I had to change it from Action<TestDataContext>in my original version to Func<TestDataContext, T>, since you want to return values ββfrom your methods.)