Created
November 8, 2011 21:11
-
-
Save jpolvora/1349242 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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