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

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -