Skip to content

Commit

Permalink
Removed new() restriction from EfRepository<>
Browse files Browse the repository at this point in the history
  • Loading branch information
ioann committed Mar 25, 2014
1 parent d6c1284 commit caddb50
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
7 changes: 3 additions & 4 deletions SharpRepository.EfRepository/EfCompoundKeyRepositoryBase.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Data;
using System.Data.Entity;
using System.Linq;
using SharpRepository.Repository;
Expand All @@ -8,7 +7,7 @@

namespace SharpRepository.EfRepository
{
public class EfCompoundKeyRepositoryBase<T> : LinqCompoundKeyRepositoryBase<T> where T : class, new()
public class EfCompoundKeyRepositoryBase<T> : LinqCompoundKeyRepositoryBase<T> where T : class
{
protected IDbSet<T> DbSet { get; private set; }
protected DbContext Context { get; private set; }
Expand Down Expand Up @@ -96,7 +95,7 @@ protected virtual void Dispose(bool disposing)
}
}

public class EfCompoundKeyRepositoryBase<T, TKey, TKey2> : LinqCompoundKeyRepositoryBase<T, TKey, TKey2> where T : class, new()
public class EfCompoundKeyRepositoryBase<T, TKey, TKey2> : LinqCompoundKeyRepositoryBase<T, TKey, TKey2> where T : class
{
protected IDbSet<T> DbSet { get; private set; }
protected DbContext Context { get; private set; }
Expand Down Expand Up @@ -184,7 +183,7 @@ protected virtual void Dispose(bool disposing)
}
}

public class EfCompoundKeyRepositoryBase<T, TKey, TKey2, TKey3> : LinqCompoundKeyRepositoryBase<T, TKey, TKey2, TKey3> where T : class, new()
public class EfCompoundKeyRepositoryBase<T, TKey, TKey2, TKey3> : LinqCompoundKeyRepositoryBase<T, TKey, TKey2, TKey3> where T : class
{
protected IDbSet<T> DbSet { get; private set; }
protected DbContext Context { get; private set; }
Expand Down
11 changes: 5 additions & 6 deletions SharpRepository.EfRepository/EfRepository.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
using System;
using System.Data.Entity;
using System.Data.Entity;
using SharpRepository.Repository;
using SharpRepository.Repository.Caching;

namespace SharpRepository.EfRepository
{
public class EfRepository<T, TKey, TKey2> : EfCompoundKeyRepositoryBase<T, TKey, TKey2> where T : class, new()
public class EfRepository<T, TKey, TKey2> : EfCompoundKeyRepositoryBase<T, TKey, TKey2> where T : class
{
public EfRepository(DbContext dbContext, ICompoundKeyCachingStrategy<T, TKey, TKey2> cachingStrategy = null)
: base(dbContext, cachingStrategy)
{
}
}

public class EfCompoundKeyRepository<T> : EfCompoundKeyRepositoryBase<T> where T : class, new()
public class EfCompoundKeyRepository<T> : EfCompoundKeyRepositoryBase<T> where T : class
{
public EfCompoundKeyRepository(DbContext dbContext, ICompoundKeyCachingStrategy<T> cachingStrategy = null)
: base(dbContext, cachingStrategy)
Expand All @@ -26,7 +25,7 @@ public EfCompoundKeyRepository(DbContext dbContext, ICompoundKeyCachingStrategy<
/// </summary>
/// <typeparam name="T">The Entity type</typeparam>
/// <typeparam name="TKey">The type of the primary key.</typeparam>
public class EfRepository<T, TKey> : EfRepositoryBase<T, TKey> where T : class, new()
public class EfRepository<T, TKey> : EfRepositoryBase<T, TKey> where T : class
{
/// <summary>
/// Initializes a new instance of the <see cref="EfRepository&lt;T, TKey&gt;"/> class.
Expand All @@ -42,7 +41,7 @@ public EfRepository(DbContext dbContext, ICachingStrategy<T, TKey> cachingStrate
/// Entity Framework repository layer
/// </summary>
/// <typeparam name="T">The Entity type</typeparam>
public class EfRepository<T> : EfRepositoryBase<T, int>, IRepository<T> where T : class, new()
public class EfRepository<T> : EfRepositoryBase<T, int>, IRepository<T> where T : class
{
/// <summary>
/// Initializes a new instance of the <see cref="EfRepository&lt;T&gt;"/> class.
Expand Down
3 changes: 1 addition & 2 deletions SharpRepository.EfRepository/EfRepositoryBase.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.ComponentModel.DataAnnotations;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Reflection;
Expand All @@ -11,7 +10,7 @@

namespace SharpRepository.EfRepository
{
public class EfRepositoryBase<T, TKey> : LinqRepositoryBase<T, TKey> where T : class, new()
public class EfRepositoryBase<T, TKey> : LinqRepositoryBase<T, TKey> where T : class
{
protected IDbSet<T> DbSet { get; private set; }
protected DbContext Context { get; private set; }
Expand Down

0 comments on commit caddb50

Please sign in to comment.