Updating excel using ado net Free american erotic video chat

Everything was ok until a few days ago I had to do a complex linq query requiring doing an union on two Db Sets (coming from two distinct repositories).

I was thrown an ugly exception letting me know that no union was possible because unions needs to be done in the same Db Context (seems logical).

To put it in a nutshell, here is what I got :** IGeneric Repository **public interface IGeneric Repository where T : class{/// The concrete implementation ***MUST*** set this context protected Ef Db Context _ef Db Context; ** Ef Db Context **public class Ef Db Context : Db Context, IData Context** IData Context ** public interface IData Context ** Concrete Repo **// IData Context is injected by NInject, In Request Scopepublic Ef Gw Config Repository(IData Context context){// Set Generic Repo context_ef Db Context = context as Ef Db Context;** NInject config **_ninject Kernel. In Request Scope(); And that's it ;)Please note that I'm far from being an expert in this field (or I wouldn't have implemented the worst approach in first place ;)), there may be better way to do this, but it worked fine for me and has the advantage of not complexifying the implementation. Also, I would love to see the complate implementation, can you put it on github or somewhere else? I do this by abstracting Db Context into an interface and injecting this using a DI tool. Here is a quoted sentence on this topic: Also, see my next post: How I use repositories is safe there. But I've been wondering if a repository is the best approach for making testable data access with the Entity Framework.

Details on my post Yes, everytime you create a new repository instance, you will have a new Db Context instance, too. I've heard some conflicting arguements that left me a bit confused.

My Db Context implementation also inherits from an interface called IData Context which is just empty (solely used for injection purposes).

The EF project would define an implementation of IGeneric Repository in the abstract class Generic Repository as was demonstrated above.

If you needed to access any other data sources, you could build out your own implemenation of the IGeneric Repository for that type of datasource, whether it be NHiberante, XML, or whatever.

In fact, I won’t touch the repository interfaces at all. Actually, it wasn't there on my code but while I was writing the post, I wanted to add there. As for your suggestion, yes it can be dropped and even as you suggested, we can have one method which accepts an optional paramater that is type of x. With a 2nd method you'd end up needing to basically duplicate the above mock but forward the where predicate to Foo Repository. comment by scott gu near the bottom) Thanks though... I want to be able to make model classes any ole way I want and persist them with EF (with some generic implementation if possible) or any other persistence model/device be it NHibernate, XML or simple Db. @Chris IGeneric Repository is not specific to the EF.

What I did here first is to create an abstract class which implements IGeneric Reposity abstract class to access an instance of Db Context. IGeneric Repository would be defined in your Model somewhere.


Leave a Reply

Your email address will not be published. Required fields are marked *