I have an issue with the context and availability in my extension methods.
Basically i am using UNITY and currently it provides me a NEW instance of my DBContext everytime i called my data layer (Its injected into the contructor).
I have also placed some extension methods for use with IQueryable that the data layer returns so i can in effect do the following.
var result = dataLayer.GetItems().WithId(3)
The withID is an extension method, i have other extension methods too where i need to do a join on a table because the tables / fields are not in my IQueryable.
Problem with this is that my dbContext is registered to give me a new instance each time so i get an error in form of "Different Contexts .....".
But i should be configuring Unity to provide me with the same instance of the dbcontext each time as the dbcontext should be SHORT LIVED. Of course if i did this i think my problem would be fixed as the Data Layer and extensions methods would be using the same DBContext object.
I have using EF 4.1 with POCO classes, there is no tracking and i have a model. Hence the only way to do joins on a additional tables is to have access to my dbcontext?
Anybody have any suggestions what my options would be ?
Thanks in advance.