Q: Creating custom repository

19 views
Skip to first unread message

Johan Eliasson

unread,
Nov 9, 2017, 5:14:24 AM11/9/17
to sharpre...@googlegroups.com
Hi!

How can I create an instance of a custom named repository?

I define it like this:

    public interface IEntryRepository : IRepository<Entry, int>
    {
    }

    public class EntryRepository : ConfigurationBasedRepository<Entry,
int>, IEntryRepository
    {
    }

But I can only create it like this:

EntryRepository repo = new EntryRepository();

I would like to do something like this:

EntryRepository repo = new EntryRepository("EntryRepository");

so that it would use the EntryRepository I defined in app.config

How should I do it?

Omar Piani

unread,
Nov 9, 2017, 5:25:32 AM11/9/17
to SharpRepository
you don't need to create EntryRepository class if you don't have any other personalizations in that

var repo = RepositoryFactory.GetInstance<Entry, int>();

Take a look here:

and 

Omar Piani

unread,
Nov 9, 2017, 5:40:45 AM11/9/17
to SharpRepository
I mean RepositoryFactory.GetInstance<Entry, int>("EntryRepository"); .. whats wrong with that?


Il giorno giovedì 9 novembre 2017 11:14:24 UTC+1, Johan Eliasson ha scritto:
Reply all
Reply to author
Forward
0 new messages