#Canducci EntityFramework Repository
PM> Install-Package CanducciEntityFrameworkRepository
##HOW TO?
Use namespace using Canducci.EntityFramework.Repository.Contracts;
The BaseEFEntities
: DbContext
and Notice
: DbSet
.
using Canducci.EntityFramework.Repository.Contracts;
namespace WebApplication1.Models
{
//abstract class
public abstract class RepositoryNoticeContract: Repository<Notice, BaseEFEntities>,
IRepository<Notice, BaseEFEntities>
{
public RepositoryNoticeContract(BaseEFEntities ctx)
: base(ctx)
{
}
}
//class concrete
public sealed class RepositoryNotice : RepositoryNoticeContract
{
public RepositoryNotice(BaseEFEntities ctx)
: base(ctx)
{
}
}
}
Configure in the Unity:
public class UnityConfig
{
private static Lazy<IUnityContainer> container = new Lazy<IUnityContainer>(() =>
{
var container = new UnityContainer();
RegisterTypes(container);
return container;
});
public static IUnityContainer GetConfiguredContainer()
{
return container.Value;
}
public static void RegisterTypes(IUnityContainer container)
{
container.RegisterType<BaseEFEntities>();
container.RegisterType<RepositoryNoticeContract, RepositoryNotice>();
}
}
Controller
public class NoticesController : Controller
{
//Dependency Injection
public readonly RepositoryNoticeContract repository;
public NoticesController(RepositoryNoticeContract repository)
{
this.repository = repository;
}
Completed Controller
public class NoticesController : Controller
{
public readonly RepositoryNoticeContract repository;
public readonly RepositoryTagsContract repositoryTags;
public NoticesController(RepositoryNoticeContract repository,
RepositoryTagsContract repositoryTags)
{
this.repository = repository;
this.repositoryTags = repositoryTags;
}
[AcceptVerbs("GET","POST")]
public async Task<ActionResult> Index(int? page, string filter)
{
int rows = 2;
ViewBag.filter = filter;
if (!string.IsNullOrEmpty(filter))
{
return View(await repository
.PaginationAsync(x => x.Title.Contains(filter),
x => x.Id, (page ?? 1), rows));
}
return View(await repository
.PaginationAsync(x => x.Id, (page ?? 1), rows));
}
[HttpGet()]
public ActionResult Create()
{
ViewBag.TagId = new SelectList(repositoryTags.List(x => x.Description),
"Id", "Description");
return View();
}
[HttpPost()]
public async Task<ActionResult> Create(Notice notice)
{
await repository.AddAsync(notice);
return RedirectToAction("Index");
}
[HttpGet()]
public async Task<ActionResult> Edit(int id)
{
Notice notice = await repository.FindAsync(id);
ViewBag.TagId = new SelectList(repositoryTags.List(x => x.Description),
"Id", "Description", notice.TagId);
return View(notice);
}
[HttpPost()]
public async Task<ActionResult> Edit(int id, Notice notice)
{
await repository.EditAsync(notice);
return RedirectToAction("Index");
}
[HttpGet()]
public async Task<ActionResult> Delete(int id)
{
return View(await repository.FindAsync(id));
}
[HttpPost()]
public async Task<ActionResult> Delete(int id, Notice notice)
{
await repository.DeleteAsync(id);
return RedirectToAction("Index");
}
}
####Methods
| Add | Edit | Delete | Find | All | List | Pagination | Count | Create | GroupBy | Sum | Query | QueryCommand | Save | GroupOrderBy | CreateAndAttach | IConfiguration | Action | IConfiguration Implementation
Example class
public class Tags
{
public int Id { get; set; }
public string Description { get; set; }
}
Repository of class Tags
BaseEFContext Context = new BaseEFContext();
RepositoryTagsContract repTags = new RepositoryTags(Context);
####Add Implementation
T Add(T Model);
IEnumerable<T> Add(IEnumerable<T> models);
//NET > 4 (Async Method).
Task<T> AddAsync(T Model);
Task<IEnumerable<T>> AddAsync(IEnumerable<T> models);
Usage:
Tags tag = new Tags();
tag.Description = "Example";
repTags.Add(tag);
Tags tag0 = new Tags();
tag0.Description = "Example 0";
Tags tag1 = new Tags();
tag1.Description = "Example 1";
repTags.Add(new List<Tags>() { tag0, tag1 });
####Edit Implementation
bool Edit(T model);
//NET > 4 (Async Method).
Task<bool> EditAsync(T model);
Usage
Tags tag = repTags.Find(1);
if (tag != null)
{
tag.Description = "Example Edit 1";
}
repTags.Edit(tag);
Or
Tags tag = repTags.Find(1);
if (tag != null)
{
tag.Description = "Example Edit 1";
repTags.Save();
}
####Delete Implementation
bool Delete(T model);
bool Delete(IEnumerable<T> model);
bool Delete(params object[] key);
bool Delete(Expression<Func<T, bool>> where);
//NET > 4 (Async Method).
Task<bool> DeleteAsync(IEnumerable<T> model);
Task<bool> DeleteAsync(T model);
Task<bool> DeleteAsync(params object[] key);
Task<bool> DeleteAsync(Expression<Func<T, bool>> where);
Usage
Tags tag = repTags.Find(1);
if (tag != null)
{
repTags.Delete(tag);
}
or
repTags.Delete(1);
or
IEnumerable<Tags> tagsList = repTags.List(x => x.Id == 1, o => o.Id, false);
repTags.Delete(tagsList);
or
repTags.Delete(x => x.Id == 1);
####Find Implementation
T Find(params object[] key);
T Find(Expression<Func<T, bool>> where);
//NET > 4 (Async Method).
Task<T> FindAsync(params object[] key);
Task<T> FindAsync(Expression<Func<T, bool>> where);
Usage
Tags tag = repTags.Find(1);
or
Tags tag1 = repTags.Find(x => x.Id == 1);
####All Implementation
IEnumerable<T> All(bool AsNoTracking = true);
IEnumerable<T> All<Tkey>(Expression<Func<T, bool>> where,
Expression<Func<T, Tkey>> orderBy, bool AsNoTracking = true);
IList<TResult> All<TResult, Tkey>(Expression<Func<T, bool>> where,
Expression<Func<T, Tkey>> orderBy, Expression<Func<T, TResult>> select,
bool AsNoTracking = true);
//NET > 4 (Async Method).
Task<IList<T>> AllAsync(bool AsNoTracking = true);
Task<IList<T>> AllAsync<Tkey>(Expression<Func<T, bool>> where,
Expression<Func<T, Tkey>> orderBy, bool AsNoTracking = true);
Task<IList<TResult>> AllAsync<TResult, Tkey>(Expression<Func<T, bool>> where,
Expression<Func<T, Tkey>> orderBy, Expression<Func<T, TResult>> select,
bool AsNoTracking = true);
Usage
IEnumerable<Tags> tagList = repTags.All(); //or repTags.All(false)
IEnumerable<Tags> tagList = repTags.All(x => x.Id == 1, o => o.Description);
//With viewModel
IEnumerable<ViewModel> viewModelList = repTags.All(
x => x.Id == 1,
o => o.Description,
x => new ViewModel() { Id = x.Id, Title = x.Description }
);
###List Implementation
IList<T> List(bool AsNoTracking = true);
IList<T> List<Tkey>(Expression<Func<T, Tkey>> orderBy, bool AsNoTracking = true);
IList<T> List<Tkey>(Expression<Func<T, Tkey>> orderBy, int page, int total = 10, bool AsNoTracking = true);
IList<T> List<Tkey>(Expression<Func<T, bool>> where, Expression<Func<T, Tkey>> orderBy,
bool AsNoTracking = true);
IList<T> List<Tkey>(Expression<Func<T, bool>> where, Expression<Func<T, Tkey>> orderBy, int page, int total = 10,
bool AsNoTracking = true);
IList<TResult> List<TResult, Tkey>(Expression<Func<T, Tkey>> orderBy,
Expression<Func<T, TResult>> select, bool AsNoTracking = true);
IList<TResult> List<TResult, Tkey>(Expression<Func<T, bool>> where,
Expression<Func<T, Tkey>> orderBy, Expression<Func<T, TResult>> select, bool AsNoTracking = true);
IList<TResult> List<TResult, Tkey>(Expression<Func<T, bool>> where,
Expression<Func<T, Tkey>> orderBy, Expression<Func<T, TResult>> select, int page, int total = 10,
bool AsNoTracking = true);
//NET > 4 (Async Method).
Task<IList<T>> ListAsync(bool AsNoTracking = true);
Task<IList<T>> ListAsync<Tkey>(Expression<Func<T, Tkey>> orderBy, bool AsNoTracking = true);
Task<IList<T>> ListAsync<Tkey>(Expression<Func<T, Tkey>> orderBy, int page, int total = 10,
bool AsNoTracking = true);
Task<IList<T>> ListAsync<Tkey>(Expression<Func<T, bool>> where, Expression<Func<T, Tkey>> orderBy,
bool AsNoTracking = true);
Task<IList<T>> ListAsync<Tkey>(Expression<Func<T, bool>> where, Expression<Func<T, Tkey>> orderBy,
int page, int total = 10, bool AsNoTracking = true);
Task<IList<TResult>> ListAsync<TResult, Tkey>(Expression<Func<T, Tkey>> orderBy,
Expression<Func<T, TResult>> select, bool AsNoTracking = true);
Task<IList<TResult>> ListAsync<TResult, Tkey>(Expression<Func<T, bool>> where,
Expression<Func<T, Tkey>> orderBy, Expression<Func<T, TResult>> select, bool AsNoTracking = true);
Task<IList<TResult>> ListAsync<TResult, Tkey>(Expression<Func<T, bool>> where,
Expression<Func<T, Tkey>> orderBy, Expression<Func<T, TResult>> select, int page, int total = 10,
bool AsNoTracking = true);
Usage
IList<Tags> tagList = repTags.List(); //or repTags.List(false);
IList<Tags> tagList = repTags.List(o => o.Description);
IList<Tags> tagList = repTags.List(x => x.Id == 1, o => o.Description);
IList<Tags> tagList = repTags.List(o => o.Description, 1, 10);
IList<Tags> tagList = repTags.List(x => x.Id == 1, o => o.Description, 1, 10);
IList<ViewModel> tagListViewModel = repTags.List(o => o.Description,
x => new ViewModel() { Id = x.Id, Title = x.Description });
IList<ViewModel> tagListViewModel = repTags.List(x => x.Id == 1, o => o.Description,
x => new ViewModel() { Id = x.Id, Title = x.Description });
IList<ViewModel> tagListViewModel = repTags.List(x => x.Id == 1, o => o.Description,
x => new ViewModel() { Id = x.Id, Title = x.Description }, 1, 10);
####Pagination Implementation
IPagedList<T> Pagination<TOrderBy>(Expression<Func<T, TOrderBy>> orderBy, int page, int total = 10);
IPagedList<TResult> Pagination<TResult, TOrderBy>(Expression<Func<T, TOrderBy>> orderBy,
Expression<Func<T, TResult>> select, int page, int total = 10);
IPagedList<T> Pagination<TOrderBy>(Expression<Func<T, bool>> where, Expression<Func<T, TOrderBy>> orderBy,
int page, int total = 10);
IPagedList<TResult> Pagination<TResult, TOrderBy>(Expression<Func<T, bool>> where,
Expression<Func<T, TOrderBy>> orderBy, Expression<Func<T, TResult>> select, int page, int total = 10);
//NET > 4 (Async Method).
Task<IPagedList<T>> PaginationAsync<TOrderBy>(Expression<Func<T, TOrderBy>> orderBy, int page, int total = 10);
Task<IPagedList<TResult>> PaginationAsync<TResult, TOrderBy>(Expression<Func<T, TOrderBy>> orderBy,
Expression<Func<T, TResult>> select, int page, int total = 10);
Task<IPagedList<T>> PaginationAsync<TOrderBy>(Expression<Func<T, bool>> where,
Expression<Func<T, TOrderBy>> orderBy, int page, int total = 10);
Task<IPagedList<TResult>> PaginationAsync<TResult, TOrderBy>(Expression<Func<T, bool>> where,
Expression<Func<T, TOrderBy>> orderBy, Expression<Func<T, TResult>> select, int page, int total = 10);
#endif
Usage
IPagedList<Tags> Pagination = repTags.Pagination(o => o.Id, 1, 10);
IPagedList<Tags> Pagination = repTags.Pagination(x => x.Id == 1, o => o.Id, 1, 10);
IPagedList<ViewModel> PaginationViewModel = repTags.Pagination(o => o.Id, x =>
new ViewModel() { Id = x.Id, Title = x.Description }, 1, 10);
IPagedList<ViewModel> PaginationViewModel = repTags.Pagination(x => x.Id == 1, o => o.Id, x =>
new ViewModel() { Id = x.Id, Title = x.Description }, 1, 10);
####Count Implementation
long Count();
long Count(Expression<Func<T, bool>> where);
//NET > 4 (Async Method).
Task<long> CountAsync();
Task<long> CountAsync(Expression<Func<T, bool>> where);
#endif
Usage
long count = repTags.Count();
long count = repTags.Count(x => x.Description.Contains("A"));
####Create Implementation
DbSet<T1> Create<T1>()
where T1 : class, new();
T Create();
Usage
Tags tag = repTags.Create();
DbSet<Notice> notice = repTags.Create<Notice>();
####GroupBy Implementation
IList<TSelect> GroupBy<TKey, TSelect>(Expression<Func<T, TKey>> keySelector,
Expression<Func<IGrouping<TKey, T>, TSelect>> select);
IList<TSelect> GroupBy<TKey, TSelect>(Expression<Func<T, bool>> where, Expression<Func<T, TKey>> keySelector,
Expression<Func<IGrouping<TKey, T>, TSelect>> select);
//NET > 4 (Async Method).
Task<IList<TSelect>> GroupByAsync<TKey, TSelect>(Expression<Func<T, TKey>> keySelector,
Expression<Func<IGrouping<TKey, T>, TSelect>> select);
Task<IList<TSelect>> GroupByAsync<TKey, TSelect>(Expression<Func<T, bool>> where,
Expression<Func<T, TKey>> keySelector, Expression<Func<IGrouping<TKey, T>, TSelect>> select);
Usage
var group = repTags.GroupBy(x => x.Id, x => new
{
Key = x.Key,
Count = x.Count()
});
var group = repTags.GroupBy(x => x.Id > 0, x => x.Id, x => new
{
Key = x.Key,
Count = x.Count()
});
####Sum Implementation
decimal Sum(Expression<Func<T, decimal>> selector);
decimal? Sum(Expression<Func<T, decimal?>> selector);
double Sum(Expression<Func<T, double>> selector);
double? Sum(Expression<Func<T, double?>> selector);
float Sum(Expression<Func<T, float>> selector);
float? Sum(Expression<Func<T, float?>> selector);
int Sum(Expression<Func<T, int>> selector);
int? Sum(Expression<Func<T, int?>> selector);
long Sum(Expression<Func<T, long>> selector);
long? Sum(Expression<Func<T, long?>> selector);
decimal Sum(Expression<Func<T, bool>> where, Expression<Func<T, decimal>> selector);
decimal? Sum(Expression<Func<T, bool>> where, Expression<Func<T, decimal?>> selector);
double Sum(Expression<Func<T, bool>> where, Expression<Func<T, double>> selector);
double? Sum(Expression<Func<T, bool>> where, Expression<Func<T, double?>> selector);
float Sum(Expression<Func<T, bool>> where, Expression<Func<T, float>> selector);
float? Sum(Expression<Func<T, bool>> where, Expression<Func<T, float?>> selector);
int Sum(Expression<Func<T, bool>> where, Expression<Func<T, int>> selector);
int? Sum(Expression<Func<T, bool>> where, Expression<Func<T, int?>> selector);
long Sum(Expression<Func<T, bool>> where, Expression<Func<T, long>> selector);
long? Sum(Expression<Func<T, bool>> where, Expression<Func<T, long?>> selector);
//NET > 4 (Async Method).
Task<decimal> SumAsync(Expression<Func<T, decimal>> selector);
Task<decimal?> SumAsync(Expression<Func<T, decimal?>> selector);
Task<double> SumAsync(Expression<Func<T, double>> selector);
Task<double?> SumAsync(Expression<Func<T, double?>> selector);
Task<float> SumAsync(Expression<Func<T, float>> selector);
Task<float?> SumAsync(Expression<Func<T, float?>> selector);
Task<int> SumAsync(Expression<Func<T, int>> selector);
Task<int?> SumAsync(Expression<Func<T, int?>> selector);
Task<long> SumAsync(Expression<Func<T, long>> selector);
Task<long?> SumAsync(Expression<Func<T, long?>> selector);
Task<decimal> SumAsync(Expression<Func<T, bool>> where, Expression<Func<T, decimal>> selector);
Task<decimal?> SumAsync(Expression<Func<T, bool>> where, Expression<Func<T, decimal?>> selector);
Task<double> SumAsync(Expression<Func<T, bool>> where, Expression<Func<T, double>> selector);
Task<double?> SumAsync(Expression<Func<T, bool>> where, Expression<Func<T, double?>> selector);
Task<float> SumAsync(Expression<Func<T, bool>> where, Expression<Func<T, float>> selector);
Task<float?> SumAsync(Expression<Func<T, bool>> where, Expression<Func<T, float?>> selector);
Task<int> SumAsync(Expression<Func<T, bool>> where, Expression<Func<T, int>> selector);
Task<int?> SumAsync(Expression<Func<T, bool>> where, Expression<Func<T, int?>> selector);
Task<long> SumAsync(Expression<Func<T, bool>> where, Expression<Func<T, long>> selector);
Task<long?> SumAsync(Expression<Func<T, bool>> where, Expression<Func<T, long?>> selector);
Usage
int soma = repTags.Sum(x => x.Id);
int soma = repTags.Sum(x => x.Id > 0, x => x.Id);
####Query Implementation
IQueryable<T> Query();
IQueryable<T> Query<T1>(params Expression<Func<T, T1>>[] includes);
DbSqlQuery<T> Query(string sql, params object[] parameters);
DbRawSqlQuery<T1> Query<T1>(string sql, params object[] parameters);
Usage
IQueryable<Tags> query0 = repTags.Query();
IQueryable<Tags> query1 = repTags.Query(x => x.Notice);
DbSqlQuery<Tags> query2 = repTags.Query("SELECT * FROM tags WHERE Id=@p0", 1);
DbRawSqlQuery<Tags> query3 = repTags.Query<Tags>("SELECT * FROM tags WHERE Id=@p0", 1);
####QueryCommand Implementation
int QueryCommand(string sql, params object[] parameters);
int QueryCommand(TransactionalBehavior transactionalBehavior, string sql,
params object[] parameters);
//NET > 4 (Async Method).
Task<int> QueryCommandAsync(string sql, params object[] parameters);
Task<int> QueryCommandAsync(string sql, CancellationToken cancellationToken,
params object[] parameters);
Task<int> QueryCommandAsync(TransactionalBehavior transactionalBehavior, string sql,
params object[] parameters);
Task<int> QueryCommandAsync(TransactionalBehavior transactionalBehavior, string sql,
CancellationToken cancellationToken, params object[] parameters);
Usage
int count = repTags.QueryCommand("INSERT INTO Tags(Description) VALUES(@p0)", "Example");
int count = repTags.QueryCommand(TransactionalBehavior.DoNotEnsureTransaction,
"INSERT INTO Tags(Description) VALUES(@p0)", "Example");
####Save Implementation
int Save();
//NET > 4 (Async Method).
Task<int> SaveAsync();
Usage
Tags tag = repTags.Find(1);
if (tag != null)
{
tag.Description = "Example Edit 1";
repTags.Save();
}
####CreateAndAttach
(Version >= 1.0.1)
Implementation
T CreateAndAttach();
Usage
Tags tag = repTags.CreateAndAttach();
tag.Description = "New Save";
repTags.Save();
####GroupOrderBy
(Version 1.0.2)
Implementation
using Canducci.EntityFramework.Repository.Util;
IPagedList<T> Pagination(GroupOrderBy<T> groupOrderBy, Expression<Func<T, bool>> where,
int page, int total = 10);
//NET > 4 (Async Method).
Task<IPagedList<T>> PaginationAsync(GroupOrderBy<T> groupOrderBy, Expression<Func<T, bool>> where,
int page, int total = 10);
Usage
GroupOrderBy<Tags> groupOrderBy = GroupOrderBy<Tags>.Create()
.Add(x => x.Description, Order.Asc)
.Add(x => x.Id, Order.Desc);
var result = repTags.Pagination(groupOrderBy, x.Title.Contains(filter), (page ?? 1), rows)
####IConfiguration
(Version 1.0.3)
Implementation
using Canducci.EntityFramework.Repository.Util;
//ALL
IEnumerable<T> All(IConfiguration<T> configuration);
IList<TResult> All<TResult>(IConfiguration<T, TResult> configuration);
//LIST
IList<T> List(IConfiguration<T> configuration);
IList<TResult> List<TResult>(IConfiguration<T, TResult> configuration);
//PAGINATION
IPagedList<T> Pagination(IConfiguration<T, T, IPagedList<T>> configuration);
IPagedList<TResult> Pagination<TResult>(IConfiguration<T, TResult, IPagedList<TResult>> configuration);
Usage
//ALL
ConfigurationOrderBy<Notice> configNotice = new ConfigurationOrderBy<Notice>();
configNotice.OrderBy.Add(x => x.Id, Order.Asc).Add(x => x.TagId, Order.Desc);
IEnumerable<Notice> n9 = rep.All(configNotice);
ConfigurationOrderBySelect<Notice, ViewModel> configNoticeViewModel =
new ConfigurationOrderBySelect<Notice, ViewModel>();
configNoticeViewModel.OrderBy.Add(x => x.Id, Order.Asc).Add(x => x.TagId, Order.Desc);
configNoticeViewModel.Select.Set(s => new ViewModel() { Id = s.Id, Title = s.Title });
IList<ViewModel> n10 = rep.All(configNoticeViewModel);
//LIST
ConfigurationOrderBy<Notice> configNotice = new ConfigurationOrderBy<Notice>();
configNotice.OrderBy.Add(x => x.Id, Order.Asc).Add(x => x.TagId, Order.Desc);
IList<Notice> n18 = rep.List(configNotice);
//PAGINATION
ConfigurationOrderByPagination<Notice> configNotice =
new ConfigurationOrderByPagination<Notice>();
configNotice.OrderBy.Add(c => c.Active);
configNotice.Page = 1;
configNotice.Total = 2;
IPagedList<Notice> p9 = rep.Pagination(configNotice);
ConfigurationOrderByPaginationSelect<Notice, ViewModel> configNoticeViewModel =
new ConfigurationOrderByPaginationSelect<Notice, ViewModel>();
configNoticeViewModel.OrderBy.Add(c => c.Active);
configNoticeViewModel.Page = 1;
configNoticeViewModel.Total = 2;
configNoticeViewModel.Select.Set(s => new ViewModel { Id = s.Id, Title = s.Title });
IPagedList<ViewModel> p10 = rep.Pagination(configNoticeViewModel);
####Action
(Version 1.0.3)
Implementation
using Canducci.EntityFramework.Repository.Util;
//ALL
IEnumerable<T> All<TConfiguration>(Action<TConfiguration> configuration)
where TConfiguration : IConfiguration<T>;
IList<TResult> All<TConfiguration, TResult>(Action<TConfiguration> configuration)
where TConfiguration : IConfiguration<T, TResult>;
//LIST
IList<T> List<TConfiguration>(Action<TConfiguration> configuration)
where TConfiguration : IConfiguration<T>;
IList<TResult> List<TConfiguration, TResult>(Action<TConfiguration> configuration)
where TConfiguration : IConfiguration<T, TResult>;
//PAGINATION
IPagedList<T> Pagination<TConfiguration>(Action<TConfiguration> configuration)
where TConfiguration : IConfiguration<T, T, IPagedList<T>>;
IPagedList<TResult> Pagination<TConfiguration, TResult>(Action<TConfiguration> configuration)
where TConfiguration: IConfiguration<T, TResult, IPagedList<TResult>>;
Usage
//ALL
IEnumerable<Notice> n11 = rep.All<ConfigurationOrderByLimit<Notice>>(a =>
{
a.OrderBy.Add(x => x.Id);
a.Page = 1;
a.Total = 2;
});
IList<ViewModel> n12 = rep.All<ConfigurationOrderBySelect<Notice, ViewModel>, ViewModel>(a =>
{
a.OrderBy.Add(x => x.Id);
a.Select.Set(s => new ViewModel { Id = s.Id, Title = s.Title });
});
//LIST
IList<Notice> n20 = rep.List<ConfigurationOrderByLimit<Notice>>(a =>
{
a.OrderBy.Add(x => x.Id);
a.Page = 1;
a.Total = 2;
});
IList<ViewModel> n21 = rep.List<ConfigurationOrderBySelect<Notice, ViewModel>, ViewModel>(a =>
{
a.OrderBy.Add(x => x.Id);
a.Select.Set(s => new ViewModel { Id = s.Id, Title = s.Title });
});
//PAGINATION
IPagedList<Notice> p11 =
rep.Pagination<ConfigurationOrderByPagination<Notice>>(a =>
{
a.OrderBy.Add(c => c.Active);
a.Page = 1;
a.Total = 2;
});
IPagedList<ViewModel> p12 =
rep.Pagination<ConfigurationOrderByPaginationSelect<Notice, ViewModel>, ViewModel>(a =>
{
a.OrderBy.Add(c => c.Active);
a.Page = 1;
a.Total = 2;
a.Select.Set(s => new ViewModel { Id = s.Id, Title = s.Title });
});
####Resume:
(Version 1.0.3)
Implementation IConfiguration<T>
and IConfiguration<T, TResult>
and IConfiguration<T, T1, TResult>
ConfigurationOrderBy<T>
ConfigurationOrderByLimit<T>
ConfigurationOrderByPagination<T>
ConfigurationOrderByPaginationSelect<T, TResult>
ConfigurationOrderBySelect<T, TResult>
ConfigurationOrderBySelectLimit<T, TResult>
ConfigurationOrderByWhere<T>
ConfigurationOrderByWherePagination<T>
ConfigurationOrderByWherePaginationSelect<T, TResult>
ConfigurationOrderByWhereSelect<T, TResult>
ConfigurationOrderByWhereSelectLimit<T, TResult>
ConfigurationWhere<T>
ConfigurationWhereLimit<T>
ConfigurationWhereSelect<T, TResult>
ConfigurationWhereSelectLimit<T, TResult>