Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added Autofac supported sample application

  • Loading branch information...
commit 6fe108638aed65f197b09317c9f67cf29eef69f4 1 parent f607bde
@ziyasal authored
Showing with 388 additions and 21 deletions.
  1. +2 −3 .gitignore
  2. +9 −0 RepositoryT.EntityFramework.AutofacConsoleSample/App.config
  3. +22 −0 RepositoryT.EntityFramework.AutofacConsoleSample/DataContextFactory.cs
  4. +8 −0 RepositoryT.EntityFramework.AutofacConsoleSample/IUserRepository.cs
  5. +54 −0 RepositoryT.EntityFramework.AutofacConsoleSample/Program.cs
  6. +36 −0 RepositoryT.EntityFramework.AutofacConsoleSample/Properties/AssemblyInfo.cs
  7. +154 −0 RepositoryT.EntityFramework.AutofacConsoleSample/RepositoryT.EntityFramework.AutofacConsoleSample.csproj
  8. +9 −0 RepositoryT.EntityFramework.AutofacConsoleSample/SampleDataContext.cs
  9. +19 −0 RepositoryT.EntityFramework.AutofacConsoleSample/User.cs
  10. +12 −0 RepositoryT.EntityFramework.AutofacConsoleSample/UserEntityRepository.cs
  11. +37 −0 RepositoryT.EntityFramework.AutofacConsoleSample/UserService.cs
  12. +9 −0 RepositoryT.EntityFramework.AutofacConsoleSample/packages.config
  13. +0 −8 RepositoryT.EntityFramework.ConsoleSample/App.config
  14. +3 −1 RepositoryT.EntityFramework.ConsoleSample/RepositoryT.EntityFramework.ConsoleSample.csproj
  15. +6 −0 RepositoryT.EntityFramework.sln
  16. +1 −2  RepositoryT.EntityFramework/DefaultContextFactory.cs
  17. +1 −1  RepositoryT.EntityFramework/EntityRepository.cs
  18. +1 −1  RepositoryT.EntityFramework/IDbContext.cs
  19. +2 −2 RepositoryT.EntityFramework/Properties/AssemblyInfo.cs
  20. +1 −1  RepositoryT.EntityFramework/SelfCommittedEntityRepository.cs
  21. +1 −2  RepositoryT.EntityFramework/UnitOfWork.cs
  22. +1 −0  packages/repositories.config
View
5 .gitignore
@@ -2,6 +2,8 @@
[Bb]in/
[Oo]bj/
[Aa]pp_Data/
+# Nuget Packages folder
+[Pp]ackages/
# mstest test results
TestResults
@@ -61,9 +63,6 @@ _ReSharper*
# Installshield output folder
[Ee]xpress
-# Nuget Packages folder
-[Pp]ackages
-
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
View
9 RepositoryT.EntityFramework.AutofacConsoleSample/App.config
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8"?>
+<configuration>
+ <configSections>
+ <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
+ </configSections>
+ <connectionStrings>
+ <add name="SampleDataContext" connectionString="Data Source=|DataDirectory|\SampleDb.sdf" providerName="System.Data.SqlServerCe.4.0" />
+ </connectionStrings>
+</configuration>
View
22 RepositoryT.EntityFramework.AutofacConsoleSample/DataContextFactory.cs
@@ -0,0 +1,22 @@
+using RepositoryT.Infrastructure;
+
+namespace RepositoryT.EntityFramework.AutofacConsoleSample
+{
+ public class DataContextFactory : IDataContextFactory<SampleDataContext>
+ {
+ private SampleDataContext _dataContext;
+
+ public SampleDataContext GetContext()
+ {
+ return _dataContext ?? (_dataContext = new SampleDataContext());
+ }
+
+ public void Dispose()
+ {
+ if (_dataContext != null)
+ {
+ _dataContext.Dispose();
+ }
+ }
+ }
+}
View
8 RepositoryT.EntityFramework.AutofacConsoleSample/IUserRepository.cs
@@ -0,0 +1,8 @@
+using RepositoryT.Infrastructure;
+
+namespace RepositoryT.EntityFramework.AutofacConsoleSample
+{
+ public interface IUserRepository : IRepository<User>
+ {
+ }
+}
View
54 RepositoryT.EntityFramework.AutofacConsoleSample/Program.cs
@@ -0,0 +1,54 @@
+using System;
+using Autofac;
+using RepositoryT.Infrastructure;
+
+namespace RepositoryT.EntityFramework.AutofacConsoleSample
+{
+ class Program
+ {
+ private static IContainer _container;
+
+ static Program()
+ {
+ InitContainer();
+ }
+
+ private static void InitContainer()
+ {
+ var builder = new ContainerBuilder();
+
+ builder.Register<IDataContextFactory<SampleDataContext>>(x => new DataContextFactory()).SingleInstance();
+ builder.Register<IUserRepository>(x => new UserEntityRepository(x.Resolve<IDataContextFactory<SampleDataContext>>())).SingleInstance();
+ builder.Register<IUnitOfWork>(x => new UnitOfWork<SampleDataContext>(x.Resolve<IDataContextFactory<SampleDataContext>>())).SingleInstance();
+ builder.Register<IUserService>(x => new UserService(x.Resolve<IUnitOfWork>(), x.Resolve<IUserRepository>())).SingleInstance();
+ _container = builder.Build();
+ }
+
+ static void Main()
+ {
+
+ IUserService userService = _container.Resolve<IUserService>();
+ User userToCreate1 = new User
+ {
+ Email = "someone@somehost.com",
+ FirstName = "Ziyasal",
+ LastName = "XYZ"
+ };
+ userService.AddUser(userToCreate1);
+ User userToCreate2 = new User
+ {
+ Email = "someone@somehost.com",
+ FirstName = "John",
+ LastName = "Doe"
+ };
+ userService.AddUser(userToCreate2);
+
+ foreach (User user in userService.GetAll())
+ {
+ Console.WriteLine("{0} {1}", user.FirstName, user.LastName);
+ }
+
+ Console.Read();
+ }
+ }
+}
View
36 RepositoryT.EntityFramework.AutofacConsoleSample/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("RepositoryT.EntityFramework.AutofacConsoleSample")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("RepositoryT.EntityFramework.AutofacConsoleSample")]
+[assembly: AssemblyCopyright("Copyright © 2012")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("3a982c74-42da-4db5-80e9-7bd2152f70ae")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
View
154 ...ityFramework.AutofacConsoleSample/RepositoryT.EntityFramework.AutofacConsoleSample.csproj
@@ -0,0 +1,154 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProjectGuid>{4DD5CE5F-DA28-4892-B41F-7F5EBF366FE2}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>RepositoryT.EntityFramework.AutofacConsoleSample</RootNamespace>
+ <AssemblyName>RepositoryT.EntityFramework.AutofacConsoleSample</AssemblyName>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ <PublishUrl>publish\</PublishUrl>
+ <Install>true</Install>
+ <InstallFrom>Disk</InstallFrom>
+ <UpdateEnabled>false</UpdateEnabled>
+ <UpdateMode>Foreground</UpdateMode>
+ <UpdateInterval>7</UpdateInterval>
+ <UpdateIntervalUnits>Days</UpdateIntervalUnits>
+ <UpdatePeriodically>false</UpdatePeriodically>
+ <UpdateRequired>false</UpdateRequired>
+ <MapFileExtensions>true</MapFileExtensions>
+ <ApplicationRevision>0</ApplicationRevision>
+ <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
+ <IsWebBootstrapper>false</IsWebBootstrapper>
+ <UseApplicationTrust>false</UseApplicationTrust>
+ <BootstrapperEnabled>true</BootstrapperEnabled>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
+ <RestorePackages>true</RestorePackages>
+ <TargetFrameworkProfile />
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <PlatformTarget>AnyCPU</PlatformTarget>
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <Prefer32Bit>false</Prefer32Bit>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <PlatformTarget>AnyCPU</PlatformTarget>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <Prefer32Bit>false</Prefer32Bit>
+ </PropertyGroup>
+ <PropertyGroup>
+ <StartupObject />
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="Autofac">
+ <HintPath>..\packages\Autofac.2.6.3.862\lib\NET40\Autofac.dll</HintPath>
+ </Reference>
+ <Reference Include="Autofac.Configuration">
+ <HintPath>..\packages\Autofac.2.6.3.862\lib\NET40\Autofac.Configuration.dll</HintPath>
+ </Reference>
+ <Reference Include="EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\packages\EntityFramework.5.0.0\lib\net40\EntityFramework.dll</HintPath>
+ </Reference>
+ <Reference Include="RepositoryT">
+ <HintPath>..\packages\RepositoryT.0.2.0\lib\RepositoryT.dll</HintPath>
+ </Reference>
+ <Reference Include="System" />
+ <Reference Include="System.ComponentModel.DataAnnotations" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Data.Entity" />
+ <Reference Include="System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
+ <Private>True</Private>
+ <HintPath>..\packages\Microsoft.SqlServer.Compact.4.0.8876.1\lib\net40\System.Data.SqlServerCe.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Data.SqlServerCe.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
+ <Private>True</Private>
+ <HintPath>..\packages\EntityFramework.SqlServerCompact.4.3.5\lib\net40\System.Data.SqlServerCe.Entity.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="System.Data.DataSetExtensions" />
+ <Reference Include="Microsoft.CSharp" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="DataContextFactory.cs" />
+ <Compile Include="IUserRepository.cs" />
+ <Compile Include="Program.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="SampleDataContext.cs" />
+ <Compile Include="User.cs" />
+ <Compile Include="UserEntityRepository.cs" />
+ <Compile Include="UserService.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="App.config">
+ <SubType>Designer</SubType>
+ </None>
+ <None Include="packages.config" />
+ </ItemGroup>
+ <ItemGroup>
+ <Content Include="SampleDb.sdf">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\RepositoryT.EntityFramework\RepositoryT.EntityFramework.csproj">
+ <Project>{9b449064-17a2-47f3-8bfd-be93637de794}</Project>
+ <Name>RepositoryT.EntityFramework</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <ItemGroup>
+ <BootstrapperPackage Include=".NETFramework,Version=v4.5">
+ <Visible>False</Visible>
+ <ProductName>Microsoft .NET Framework 4.5 %28x86 and x64%29</ProductName>
+ <Install>true</Install>
+ </BootstrapperPackage>
+ <BootstrapperPackage Include="Microsoft.Net.Client.3.5">
+ <Visible>False</Visible>
+ <ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
+ <Install>false</Install>
+ </BootstrapperPackage>
+ <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
+ <Visible>False</Visible>
+ <ProductName>.NET Framework 3.5 SP1</ProductName>
+ <Install>false</Install>
+ </BootstrapperPackage>
+ <BootstrapperPackage Include="Microsoft.SQL.Server.Compact.4.0">
+ <Visible>False</Visible>
+ <ProductName>SQL Server Compact 4.0 SP1</ProductName>
+ <Install>true</Install>
+ </BootstrapperPackage>
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <Import Project="$(SolutionDir)\.nuget\nuget.targets" />
+ <PropertyGroup>
+ <PostBuildEvent>
+ if not exist "$(TargetDir)x86" md "$(TargetDir)x86"
+ xcopy /s /y "$(SolutionDir)packages\Microsoft.SqlServer.Compact.4.0.8876.1\NativeBinaries\x86\*.*" "$(TargetDir)x86"
+ if not exist "$(TargetDir)amd64" md "$(TargetDir)amd64"
+ xcopy /s /y "$(SolutionDir)packages\Microsoft.SqlServer.Compact.4.0.8876.1\NativeBinaries\amd64\*.*" "$(TargetDir)amd64"</PostBuildEvent>
+ </PropertyGroup>
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
View
9 RepositoryT.EntityFramework.AutofacConsoleSample/SampleDataContext.cs
@@ -0,0 +1,9 @@
+using System.Data.Entity;
+
+namespace RepositoryT.EntityFramework.AutofacConsoleSample
+{
+ public class SampleDataContext : DbContext, IDbContext
+ {
+ public DbSet<User> Users { get; set; }
+ }
+}
View
19 RepositoryT.EntityFramework.AutofacConsoleSample/User.cs
@@ -0,0 +1,19 @@
+using System.ComponentModel.DataAnnotations;
+
+namespace RepositoryT.EntityFramework.AutofacConsoleSample
+{
+ public class User
+ {
+ [Key]
+ public int Id { get; set; }
+
+ [Required]
+ public string Email { get; set; }
+
+ [Required]
+ public string FirstName { get; set; }
+
+ [Required]
+ public string LastName { get; set; }
+ }
+}
View
12 RepositoryT.EntityFramework.AutofacConsoleSample/UserEntityRepository.cs
@@ -0,0 +1,12 @@
+using RepositoryT.Infrastructure;
+
+namespace RepositoryT.EntityFramework.AutofacConsoleSample
+{
+ public class UserEntityRepository : EntityRepository<User, SampleDataContext>, IUserRepository
+ {
+ public UserEntityRepository(IDataContextFactory<SampleDataContext> databaseFactory)
+ : base(databaseFactory)
+ {
+ }
+ }
+}
View
37 RepositoryT.EntityFramework.AutofacConsoleSample/UserService.cs
@@ -0,0 +1,37 @@
+using System.Collections.Generic;
+using RepositoryT.Infrastructure;
+
+namespace RepositoryT.EntityFramework.AutofacConsoleSample
+{
+ //Basic service class :) For detailed implementation look at:
+ //https://github.com/ziyasal/RepositoryT.RavenDb/tree/master/RepositoryT.RavenDb.Mvc4AutofacUOWSample/SampleBase
+ public interface IUserService
+ {
+ int AddUser(User user);
+ IEnumerable<User> GetAll();
+ }
+
+ public class UserService : IUserService
+ {
+ private readonly IUnitOfWork _unitOfWork;
+ private readonly IUserRepository _userRepository;
+
+ public UserService(IUnitOfWork unitOfWork, IUserRepository userRepository)
+ {
+ _unitOfWork = unitOfWork;
+ _userRepository = userRepository;
+ }
+
+ public int AddUser(User user)
+ {
+ _userRepository.Add(user);
+ _unitOfWork.Commit();
+ return user.Id;
+ }
+
+ public IEnumerable<User> GetAll()
+ {
+ return _userRepository.GetAll();
+ }
+ }
+}
View
9 RepositoryT.EntityFramework.AutofacConsoleSample/packages.config
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+ <package id="Autofac" version="2.6.3.862" targetFramework="net45" />
+ <package id="EntityFramework" version="5.0.0" targetFramework="net40" />
+ <package id="EntityFramework.SqlServerCompact" version="4.3.5" targetFramework="net40" />
+ <package id="Microsoft.SqlServer.Compact" version="4.0.8876.1" targetFramework="net45" />
+ <package id="RepositoryT" version="0.2.0" targetFramework="net45" />
+ <package id="SqlServerCompact" version="4.0.8854.1" targetFramework="net45" />
+</packages>
View
8 RepositoryT.EntityFramework.ConsoleSample/App.config
@@ -1,17 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
- <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<connectionStrings>
<add name="SampleDataContext" connectionString="Data Source=|DataDirectory|\SampleDb.sdf" providerName="System.Data.SqlServerCe.4.0" />
</connectionStrings>
- <entityFramework>
- <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
- <parameters>
- <parameter value="v11.0" />
- </parameters>
- </defaultConnectionFactory>
- </entityFramework>
</configuration>
View
4 RepositoryT.EntityFramework.ConsoleSample/RepositoryT.EntityFramework.ConsoleSample.csproj
@@ -74,7 +74,9 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
- <None Include="App.config" />
+ <None Include="App.config">
+ <SubType>Designer</SubType>
+ </None>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
View
6 RepositoryT.EntityFramework.sln
@@ -12,6 +12,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{ABBA9A
.nuget\NuGet.targets = .nuget\NuGet.targets
EndProjectSection
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RepositoryT.EntityFramework.AutofacConsoleSample", "RepositoryT.EntityFramework.AutofacConsoleSample\RepositoryT.EntityFramework.AutofacConsoleSample.csproj", "{4DD5CE5F-DA28-4892-B41F-7F5EBF366FE2}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -26,6 +28,10 @@ Global
{20DEFB49-92C1-46BF-8374-56A9949AE7EF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{20DEFB49-92C1-46BF-8374-56A9949AE7EF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{20DEFB49-92C1-46BF-8374-56A9949AE7EF}.Release|Any CPU.Build.0 = Release|Any CPU
+ {4DD5CE5F-DA28-4892-B41F-7F5EBF366FE2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {4DD5CE5F-DA28-4892-B41F-7F5EBF366FE2}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {4DD5CE5F-DA28-4892-B41F-7F5EBF366FE2}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {4DD5CE5F-DA28-4892-B41F-7F5EBF366FE2}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
View
3  RepositoryT.EntityFramework/DefaultContextFactory.cs
@@ -1,10 +1,9 @@
using System;
-using System.Data.Entity;
using RepositoryT.Infrastructure;
namespace RepositoryT.EntityFramework
{
- public class DefaultDataContextFactory<TContext> : IDataContextFactory<TContext> where TContext :DbContext, IDisposable, new()
+ public class DefaultDataContextFactory<TContext> : IDataContextFactory<TContext> where TContext : class,IDbContext, IDisposable, new()
{
private TContext _dataContext;
View
2  RepositoryT.EntityFramework/EntityRepository.cs
@@ -10,7 +10,7 @@ namespace RepositoryT.EntityFramework
{
public abstract class EntityRepository<T, TContext> : RepositoryBase<TContext>
where T : class
- where TContext : DbContext, IDisposable
+ where TContext : class, IDbContext, IDisposable
{
private readonly IDbSet<T> _dbset;
View
2  RepositoryT.EntityFramework/IDbContext.cs
@@ -6,7 +6,7 @@
namespace RepositoryT.EntityFramework
{
- public interface IDbContext
+ public interface IDbContext : IDisposable
{
DbSet<TEntity> Set<TEntity>() where TEntity : class;
DbSet Set(Type entityType);
View
4 RepositoryT.EntityFramework/Properties/AssemblyInfo.cs
@@ -31,5 +31,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("0.2.1.0")]
-[assembly: AssemblyFileVersion("0.2.1.0")]
+[assembly: AssemblyVersion("0.3.0.0")]
+[assembly: AssemblyFileVersion("0.3.0.0")]
View
2  RepositoryT.EntityFramework/SelfCommittedEntityRepository.cs
@@ -10,7 +10,7 @@ namespace RepositoryT.EntityFramework
{
public class SelfCommittedEntityRepository<T, TContext> : EntityRepository<T, TContext>
where T : class
- where TContext : DbContext, IDisposable
+ where TContext : class, IDbContext, IDisposable
{
private readonly IDbSet<T> _dbset;
View
3  RepositoryT.EntityFramework/UnitOfWork.cs
@@ -1,10 +1,9 @@
using System;
-using System.Data.Entity;
using RepositoryT.Infrastructure;
namespace RepositoryT.EntityFramework
{
- public class UnitOfWork<TContext> : UnitOfWorkBase<TContext> where TContext : DbContext, IDisposable, new()
+ public class UnitOfWork<TContext> : UnitOfWorkBase<TContext> where TContext : class ,IDbContext, IDisposable, new()
{
public UnitOfWork(IDataContextFactory<TContext> databaseFactory)
View
1  packages/repositories.config
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<repositories>
+ <repository path="..\RepositoryT.EntityFramework.AutofacConsoleSample\packages.config" />
<repository path="..\RepositoryT.EntityFramework.ConsoleSample\packages.config" />
<repository path="..\RepositoryT.EntityFramework\packages.config" />
</repositories>
Please sign in to comment.
Something went wrong with that request. Please try again.