0
andmattia created
Is possible to access to a entity (via manager) in a static class?
I have a method and I make a static extension if I want to give data from data base is possibile to do that? How?
mattia
2 Answer(s)
-
0
Possible, but not suggested (because statics are bad, breaks testability). Short answer:
var yourEntity = IocManager.Instance.Resolve<IRepository<YourEntity>>().Get(42); //42 is the id of your entity.
A better code should use ResolveAsDisposable in a using statement, but I did write like that for simplicity.
-
0
Thank for your replay @hikalkan.
Ok I need to change my approch and use IOC from manager without do it on static class.
mat