I'm trying to implement the Repository Pattern with UoW for our small Application. As far as i read the main Idea of the UoW is to expose the Repositories via one Context and to Save all Stuff in one step, f.e. with Transaction, to make sure the Operations are atomic.
Everything fine so far and I checked the examples like http://www.asp.net/mvc/tutorials/getting-started-with-ef-5-using-mvc-4/implementing-the-repository-and-unit-of-work-patterns-in-an-asp-net-mvc-application
The problem: We have a logical BusinessModel, which gets Data from the TFS API and a SQL-Database using Entitiy Framework. So we have seperate Systems and no Contexts. UoW still seems a good Idea to implement (Rollback, if one System could not save properly etc.), but does it need Repository as well? If I create a Repository, which hold just a List of the logical BusinessModel and gets the Data from EF/TFS API, I could do everything I'd like to in it.
Did I understand these two Concepts wrong? Or is just our environment not workingfor this Patterns?
Thanks in advance
Matthias
Edit: To show what I mean: We have a DataLayer.TFS Project, which we can query TFS-relevant data like this:
IEnumerable<WorkItem> tfsItems = TFS.QueryByParameter(criterias);
And we have a DataLayer.SQL Project, where we have the EF and query data like this:
using (var context = new SimpleContextContainer())
{
//Some Tables to List etc.
}
Then we have a ugly procedure called Concat, which merges the two Lists:
private static List<NewItem> Concat(IEnumerable<WorkItem> tfsItems, IEnumerable<OldDBItem> dbItems)
{
List<NewItem> result = new List<NewItem>();
foreach(var tfsItem in tfsItems)
{
var tmpItem = new NewItem();
tmpItem.PbiId = tfsItem.Id;
//Do this for all properties
result.Add(tmpItem);
}
return result;
}
And we have an opposite Prodecure for splitting the Data.