Skip to content

Instantly share code, notes, and snippets.

@jpolvora
Created November 8, 2011 21:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jpolvora/1349242 to your computer and use it in GitHub Desktop.
Save jpolvora/1349242 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Linq;
using Metavision.Infra.Data;
namespace Metavision.Infra.Extensions
{
public static class DataExtensions
{
#region extensoes para Repositório
public static void RemoveMany<T>(this IRepositorio<T> repositorio, Func<T, bool> where) where T : class, new()
{
if (repositorio == null) return;
var results = repositorio.GetAll(where);
foreach (var result in results)
{
repositorio.RemoveEntity(result);
}
}
public static IQueryable<T> GetQueryable<T>(this IRepositorio<T> repositorio) where T : class, new()
{
return repositorio.GetAll().AsQueryable();
}
public static PagedResult<T> GetPagedResult<T>(this IQueryable<T> queryable, int size) where T : class, new()
{
return new PagedResult<T>(queryable, size);
}
internal static void AttachToUnitOfWork(this IRepositorio repositorio)
{
if (repositorio == null) return;
if (repositorio.UnitOfWork is UnitOfWorkBase)
{
((UnitOfWorkBase)repositorio.UnitOfWork).AttachRepository(repositorio);
}
}
#endregion
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment