c# - How to register generic service -
this question has answer here:
i planning move system generic service layer.
public interface iabcservice<tentity> tentity : class public class abcservice<tentity> : iabcservice<tentity> tentity : class
i tried not work.
services.addtransient<typeof(iabcservice<myentity>), abcservice(); .... .... ....
i'm using of entities , along trying add properties.
how can register generic service in asp.net core?
i wanted try exact same thing before , i've got work this:
services.addtransient(typeof(iabcservice<>), typeof(abcservice<>)); services.addtransient(typeof(iabcservice<person>), typeof(abcservice<person>));
do mind different structure, registering parameters in method.
to elaborate, can see in example above, new dnx framework package can register both open , closed generics. try out, both lines work.
Comments
Post a Comment