Skip to content

RepositoryAttribute

Aghyad khlefawi edited this page Apr 21, 2017 · 1 revision

Marks a class as a repository. This attribute have a single constructor that takes the implemented interface Type as parameter.

C# Example:

//The data model
public class Person : IUniqueObject<int>
{
    public int ID { get; set; }
    public string FirstName { get; set; }
    public string LastName { get; set; }
    public int GetKey { get { return ID; } }
}

//Defining the repository interface
public interface IPersonRepository : ICRUDRepository<Person, int>
{
}

//Defining the repository
[Repository(typeof(IPersonRepository))]
public class PersonRepository : CRUDMongoRepositoryBase<Company, int>, IPersonRepository
{
}

Clone this wiki locally