Skip to content

Latest commit

 

History

History
38 lines (32 loc) · 1005 Bytes

README.md

File metadata and controls

38 lines (32 loc) · 1005 Bytes

build status

MongoRepository.Cached

Cache feature for MongoRepository

Definition

Model

You don't need to create a model, but if you are doing so you need to extend Entity

	//if you are able to define your model
	public class User : Entity
	{
		public string Username { get; set; }
		public string Password { get; set; }
	}

Repository

There are multiple base constructors, read summaries of others

	public class UserRepository : CachedRepository<User>
	{
		public UserRepository(string connectionString) : base(connectionString) {}

		//custom method
		public User FindbyUsername(string username)
		{
			return First(i => i.Username == username);
		}
		
		//custom method2
		public void UpdatePassword(User item, string newPassword)
		{
			repo.Update(item, i => i.Password, newPassword);
		}
	}