What is a POCO Proxy? - poco

I came across this term while working on ADO.net entity framework (EF 4.0). It's hard for me to understand this term. I am aware of POCO classes and their use in creating PI model but I am not sure about a POCO proxy.
Can anyone help on this?

Are you familiar with dependency injection (DI)? POCO proxies are a form of DI:
http://blogs.msdn.com/b/adonet/archive/2009/12/22/poco-proxies-part-1.aspx

It refers to the technique used to accomplish persistence ignorance where the object is instantiated as a proxy at runtime. Castle has a proxying framework that you might want to look at to see what sort of thing you can use proxies for. Castle Dynamic Proxy

Related

Porting Rhino Security to Entity Framework - Why is it not there already?

I am using (Code First) Entity Framework 4.3 for an ASP.NET MVC project, and wanted to implement granular Permission based authorization features as provided by Rhino Security
Though it is the only such Permission based Lib available, but it's not yet been ported to EF. What can be the reason,
Such a Permission Framework is not a usual requirement in projects, so it's not so famous
Entity Framework is not so effective and so is not as ubiquitous as NHibernate
Rhino Repository is so tightly coupled with NHibernate that it's not possible to simply port it to EF
Most Important, If i really insist on using it with EF, and if you tell me it's not possible, can you please help me understand why. And if your answer is in YES, can you please help me with HOW TO DO IT
ANY OTHER IDEAS please
If I really get started implementing it using EF, would it be a futile endeavor. Any complications i would face.
As I am just a newbie both with Entity Framework and MVC, is there anything I am overlooking. So, please help me all GENIUSES out there.
Any ideas how to get started?
My opinion:
It cannot be ported directly. Rhino-Security follows concept of separating (abstracting) security from your domain model. This separation is done through IUser interface. Implementing IUser interface in your User class will be the only connection between your domain model and the security infrastructure provided by the framework. Here comes the problem. EF doesn't currently support interfaces so you cannot use an interface instead of a real entity type in the mapping and you cannot have an interface instead of a real entity type as a navigation property in your entities. Because of that Rhino-Security cannot be ported to EF without crippling its main idea - you will have to create User entity directly in ported security library and all applications will have to be dependent on that User implementation.
I'd say the third answer:
Rhino Repository is so tightly coupled with NHibernate that it's not
possible to simply port it to EF
I'm not sure about what's the reason behind that, but I'm sure it's closely bounded to NHibernate (or to Castle Active Record, that is based on NHibernate)

Dependency injection need some explanation

I have been working alot on MVC3 now a days and use Dependency Injection ninject etc.
I find it useful in Testing, don't make concrete implementation of classes like Model but instead injected.
My Questions:
How do we explain DI. Any simple definition to it.?
The benefits of DI?
Can we use DI in ASP.NET web forms?
Thanks
Dependency injection is eliminating the objects dependencies of concrete classes.
Benefits:
It allowed to use an abstract interface instead of a concrete class.
This makes lots of (large) applications to be more manageable, if you need to swap out a class, its easier to inherit from an interface and make the IoC container switch to another class.
And if you're looking to use DI in ASP.NET Web Forms in the business logic, yes you can.
Dependency injection means giving an object its instance variables.
Here is a great article about it:
http://jamesshore.com/Blog/Dependency-Injection-Demystified.html.
Can't be simplier, I think.
Benefits: Loose coupling. Easy implementation changes by just editing config file. Easy testing with mocks.
In WebForms? Sure, I've been working on a project where we successfully used Castle Windsor to inject our Repositories.
Brad Wilson has a really good ASP.NET MVC 3 Service Location blog series. It may help you see the value.

dependency injection using unity on custom session store provider

I made a custom SessionStateStore provider, however the dependencies were not resolving. I used Unity for DI.
I googled a lot about this problem and got some useful hints, but still I can't get it right.
the providers are constructed and managed by the framework, and there is no opportunity for us to intercept that construction to provide additional dependency injection
override the Initialize() method in your custom provider, and do the dependency injection there
There's a similar problem and a decent solution here and here(StructureMap, not Unity), but I can't get it right.
Please help. Thanks.
Providers are really painful things. There's really no nice way to address this problem, but a practical way is to handle the provider as a Composition Root - in other words, as if it was the entry point of the application. Within the provider you can compose all of your services.
If you use a DI Container (like Unity) you can store the container instance in HttpContext and get it from there to compose your object graph from within the provider.

Castle Windsor IOC with Custom .NET Membership?

I have read about not being able to use a .NET Custom Membership with Castle Windor. Is this the case? Are there any work arounds?
There are always workarounds. In this case you have to implement a proxy pattern. You need to create an interface & an implementing object that proxies calls to the membership class.
There are also some interesting blogs about duck typing with windsor. By using duck typing could eliminate the need to create the proxy object yourself. You would only have to write an interface containing the methods you want to use from the membership class and Castle would take care of proxying the calls for you (but essentially it's the same pattern).

caching per request in ASP.NET?

I'm using both IBatis.NET and Spring.NET on a project at work and I'd like to figure out if I can leverage both/either frameworks to achieve "per-request caching" on all calls into my DAL layer. In other words, every time an HTTP request is served by ASP.NET, I would like first call into a DAL method to hit the remote DB, but all calls thereafter to be inflated from cache.
I've seen a few articles describe a way to achieve this using HttpContext.Current, but I can't stomach the idea of polluting my DAL layer with System.Web references. I'd also like to leverage these frameworks if at possible as I'm not fond of re-inventing the wheel.
I'm no expert on IBatis.NET and integration with Spring.NET most likely more thank lacking but here goes..
I would create a custom ICache implementation that uses HttpContext.Current.Items. Then I would make DAL layer objects proxied with Spring.NET AOP (they are behind interfaces, aren't they?). Then it's just a matter of applying the cache advice using the AOP framework.
You should be able to do this by following Spring.NET documentation about AOP caching and implement the ICache using Spring.NET's ASP.NET cache implementation as starting point.

Resources