Click here to Skip to main content
15,867,308 members
Articles / Web Development / HTML

Code First Approach using Entity Framework 4.1, Inversion of Control, Unity Framework, Repository & Unit of Work Pattern and MVC3 Razor View

Rate me:
Please Sign up or sign in to vote.
4.90/5 (76 votes)
26 Nov 2014CPOL16 min read 228.5K   15.3K   187  
My effort in this article was to put some light on building a generic multilayered architecture using Entity Framework 4.1 and MVC3 razor view engine.
  • SourceCode.zip
    • CodeFirstData
    • CodeFirstEntities
      • _ReSharper.CodeFirstEntities
        • AspFileDataCache.dat
        • BuildScriptCache
          • .crc
          • .version
          • 1
            • 79c652.dat
        • CompletionStatistics
          • Statistics.dat
        • ConditionalNames
          • .crc
          • .version
          • 4
            • 3fddd5b7.dat
        • JavaScriptCache
          • .crc
          • .version
          • 1
            • 545da353.dat
            • 61d4b734.dat
          • 2
            • 3245028f.dat
          • 3
            • 23ce8008.dat
          • 4
            • 3fddd5b7.dat
          • 5
            • 71112476.dat
          • 7
            • 3bd63.dat
          • 8
            • 69c2350.dat
        • JSTest
          • .crc
          • .version
          • 7
            • 337c7624.dat
        • ModuleIds.xml
        • MVC
          • .crc
          • .version
          • 7
            • 337c7624.dat
        • NamedArguments
          • .crc
          • .version
          • 4
            • 3fddd5b7.dat
        • PersistenIdIndex.bin
        • RecentItems
          • RecentFiles.dat
        • Resources
          • .crc
          • .version
        • SymbolCache.bin
        • TagPrefixes
          • .crc
          • .version
          • 1
            • 79c652.dat
        • TodoItems
          • .crc
          • .version
          • 4
            • 3fddd5b7.dat
        • WebSymbols
          • .crc
          • .version
          • 1
            • 79c652.dat
        • WordIndex
          • .crc
          • .version
          • 3
            • 23ce8008.dat
            • 525a768.dat
          • 4
            • 3fddd5b7.dat
          • 7
            • 278dea1d.dat
        • XmlIndex
          • Accessibility.xml
            • 59F683E5.bin
            • 97C5C74B.bin
          • EntityFramework.xml
            • 6E572F9F.bin
            • EF3E2830.bin
          • Microsoft.Build.Framework.4.0.0.0.Nullness.Generated.xml
            • 91BD6FD3.bin
          • Microsoft.Build.Framework.xml
            • 5B4D04B5.bin
          • Microsoft.Build.Tasks.v4.0.4.0.0.0.Nullness.Generated.xml
            • AB623953.bin
          • Microsoft.Build.Tasks.v4.0.xml
            • 390E8A25.bin
          • Microsoft.Build.Utilities.v4.0.4.0.0.0.Nullness.Generated.xml
            • 07D57913.bin
          • Microsoft.Build.Utilities.v4.0.xml
            • 1A2D939D.bin
          • Microsoft.CSharp.4.0.0.0.Nullness.Generated.xml
            • 10F25633.bin
          • Microsoft.CSharp.xml
            • 4DDA1CCA.bin
          • Microsoft.JScript.10.0.0.0.Nullness.Generated.xml
            • 47DE7F86.bin
          • Microsoft.JScript.xml
            • F74F3354.bin
          • Microsoft.Practices.Unity.Configuration.xml
            • 5AA51D65.bin
            • 70886068.bin
          • Microsoft.Practices.Unity.Interception.Configuration.xml
            • 209059E5.bin
            • 4E009688.bin
          • Microsoft.Practices.Unity.Interception.xml
            • 59AC76BB.bin
            • E837E3D6.bin
          • Microsoft.Practices.Unity.xml
            • ABA3AEF6.bin
            • CC291A3B.bin
          • Microsoft.Transactions.Bridge.3.0.0.0.Nullness.Generated.xml
            • C7619374.bin
          • Microsoft.Transactions.Bridge.4.0.0.0.Nullness.Generated.xml
            • CB57B7D3.bin
          • Microsoft.Transactions.Bridge.xml
            • 196DF037.bin
          • Microsoft.VisualBasic.10.0.0.0.Contracts.xml
            • 905D2256.bin
          • Microsoft.VisualBasic.10.0.0.0.Nullness.Generated.xml
            • 34A06846.bin
          • Microsoft.VisualBasic.10.0.0.0.Pure.xml
            • 90D5FE85.bin
          • Microsoft.VisualBasic.Activities.Compiler.10.0.0.0.Nullness.Generated.xml
            • 276128C6.bin
          • Microsoft.VisualBasic.xml
            • EE79FEBF.bin
          • Microsoft.VisualC.xml
            • 3732B488.bin
            • 90D3ABE6.bin
          • mscorlib.2.0.0.0.Contracts.xml
            • 2C2FE705.bin
          • mscorlib.2.0.0.0.Interfaces.Nullness.Generated.xml
            • C418674D.bin
          • mscorlib.2.0.0.0.Nullness.Generated.xml
            • E2B19D75.bin
          • mscorlib.2.0.0.0.Pure.xml
            • B22E2EB6.bin
          • mscorlib.4.0.0.0.Contracts.xml
            • 0DED0883.bin
          • mscorlib.4.0.0.0.Interfaces.Nullness.Generated.xml
            • 620DC5CB.bin
          • mscorlib.4.0.0.0.Nullness.Generated.xml
            • 772ECBB3.bin
          • mscorlib.4.0.0.0.Pure.xml
            • 6572C670.bin
          • mscorlib.I18n.xml
            • 366D6FC8.bin
          • mscorlib.Nullness.Manual.xml
            • A029C282.bin
          • mscorlib.ValueFlow.xml
            • 4E59B0BF.bin
          • mscorlib.xml
            • 05998BE8.bin
            • 1D362982.bin
            • 743ADB6C.bin
          • SMDiagnostics.3.0.0.0.Nullness.Generated.xml
            • 8AA32174.bin
          • SMDiagnostics.4.0.0.0.Nullness.Generated.xml
            • 8E9945D3.bin
          • System.2.0.0.0.Contracts.xml
            • 929BDA85.bin
          • System.2.0.0.0.Nullness.Generated.xml
            • BE8780F5.bin
          • System.2.0.0.0.Pure.xml
            • 8CF3F236.bin
          • System.4.0.0.0.Contracts.xml
            • 7458FC03.bin
          • System.4.0.0.0.Nullness.Generated.xml
            • 5304AF33.bin
          • System.4.0.0.0.Pure.xml
            • 403889F0.bin
          • System.Activities.4.0.0.0.Nullness.Generated.xml
            • 679C2793.bin
          • System.Activities.DurableInstancing.4.0.0.0.Nullness.Generated.xml
            • 5B8A77D3.bin
          • System.Activities.DurableInstancing.xml
            • 04D57C40.bin
          • System.Activities.xml
            • 33E2C3AB.bin
          • System.ComponentModel.DataAnnotations.3.5.0.0.Nullness.Generated.xml
            • B5111ED1.bin
          • System.ComponentModel.DataAnnotations.4.0.0.0.Nullness.Generated.xml
            • EB11BC93.bin
          • System.ComponentModel.DataAnnotations.I18n.xml
            • E1E89968.bin
          • System.ComponentModel.DataAnnotations.xml
            • 13D34939.bin
            • B9A8C76A.bin
          • System.Configuration.2.0.0.0.Contracts.xml
            • 93875E45.bin
          • System.Configuration.2.0.0.0.Nullness.Generated.xml
            • FB5BB8B5.bin
          • System.Configuration.2.0.0.0.Pure.xml
            • 07AB3D76.bin
          • System.Configuration.4.0.0.0.Contracts.xml
            • 8AA99CC3.bin
          • System.Configuration.4.0.0.0.Nullness.Generated.xml
            • 5C04A9F3.bin
          • System.Configuration.4.0.0.0.Pure.xml
            • A30FD330.bin
          • System.Configuration.Install.2.0.0.0.Contracts.xml
            • BF2FCAE5.bin
          • System.Configuration.Install.2.0.0.0.Nullness.Generated.xml
            • 03AF4D15.bin
          • System.Configuration.Install.4.0.0.0.Contracts.xml
            • F6158D63.bin
          • System.Configuration.Install.4.0.0.0.Nullness.Generated.xml
            • 28353B53.bin
          • System.Configuration.Install.xml
            • 3B89BCB1.bin
            • 7FB1C71F.bin
          • System.Configuration.xml
            • 092A1070.bin
            • 2AA4525E.bin
          • System.Core.3.5.0.0.Contracts.xml
            • 1D445C21.bin
          • System.Core.3.5.0.0.Nullness.Generated.xml
            • 585EA4D1.bin
          • System.Core.3.5.0.0.Pure.xml
            • C497F7D2.bin
          • System.Core.4.0.0.0.Contracts.xml
            • 9A69C6A3.bin
          • System.Core.4.0.0.0.Nullness.Generated.xml
            • 8E5F4293.bin
          • System.Core.4.0.0.0.Pure.xml
            • D7464B10.bin
          • System.Core.LinqTunnel.xml
            • 63F26974.bin
          • System.Core.Nullness.Manual.xml
            • 31BDD0E2.bin
          • System.Core.xml
            • 11686E5B.bin
            • 944CB108.bin
          • System.Data.2.0.0.0.Contracts.xml
            • C6AE46A5.bin
          • System.Data.2.0.0.0.Nullness.Generated.xml
            • A9765ED5.bin
          • System.Data.2.0.0.0.Pure.xml
            • A61761D6.bin
          • System.Data.4.0.0.0.Contracts.xml
            • 68A7E423.bin
          • System.Data.4.0.0.0.Nullness.Generated.xml
            • 7A169013.bin
          • System.Data.4.0.0.0.Pure.xml
            • 595BF890.bin
          • System.Data.DataSetExtensions.4.0.0.0.Nullness.Generated.xml
            • DB866913.bin
          • System.Data.DataSetExtensions.I18n.xml
            • B16CE5E8.bin
          • System.Data.DataSetExtensions.xml
            • 4A8BA0A6.bin
          • System.Data.Entity.3.5.0.0.Nullness.Generated.xml
            • FAE5A5D1.bin
          • System.Data.Entity.4.0.0.0.Nullness.Generated.xml
            • 30E64393.bin
          • System.Data.Entity.xml
            • 9398E105.bin
            • EB528336.bin
          • System.Data.I18n.xml
            • 51BDCCE8.bin
          • System.Data.Linq.3.5.0.0.Nullness.Generated.xml
            • 3938B6B1.bin
          • System.Data.Linq.4.0.0.0.Nullness.Generated.xml
            • 0D37D4F3.bin
          • System.Data.Linq.Attributes.xml
            • B77F6C29.bin
          • System.Data.Linq.I18n.xml
            • A25BD988.bin
          • System.Data.Linq.xml
            • 34869A17.bin
            • B30DAF64.bin
          • System.Data.OracleClient.2.0.0.0.Nullness.Generated.xml
            • 7754BD95.bin
          • System.Data.OracleClient.4.0.0.0.Nullness.Generated.xml
            • 9BDAABD3.bin
          • System.Data.OracleClient.xml
            • 27DDCE31.bin
            • 9427B35F.bin
          • System.Data.Services.Client.3.5.0.0.Nullness.Generated.xml
            • 2ADFF3D1.bin
          • System.Data.Services.Client.4.0.0.0.Nullness.Generated.xml
            • 60E09193.bin
          • System.Data.Services.Client.xml
            • 0B993FC7.bin
            • 3CEE3C54.bin
          • System.Data.Services.Design.3.5.0.0.Nullness.Generated.xml
            • C417FF51.bin
          • System.Data.Services.Design.4.0.0.0.Nullness.Generated.xml
            • FA189D13.bin
          • System.Data.Services.Design.xml
            • CC0FCF1F.bin
            • E842CE0C.bin
          • System.Data.SqlXml.2.0.0.0.Nullness.Generated.xml
            • 956E4495.bin
          • System.Data.SqlXml.4.0.0.0.Nullness.Generated.xml
            • B9F432D3.bin
          • System.Data.SqlXml.xml
            • 48CF6F29.bin
            • 8761C3C7.bin
          • System.Data.xml
            • 7BF6DA70.bin
            • CFFAA41E.bin
          • System.Deployment.2.0.0.0.Nullness.Generated.xml
            • E0B9A455.bin
          • System.Deployment.4.0.0.0.Nullness.Generated.xml
            • B159D593.bin
          • System.Deployment.xml
            • 2C6EE0D7.bin
            • CC017739.bin
          • System.Design.2.0.0.0.Nullness.Generated.xml
            • 73443E95.bin
          • System.Design.4.0.0.0.Nullness.Generated.xml
            • 97CA2CD3.bin
          • System.Design.xml
            • 66D504B2.bin
            • 94F2BB5C.bin
          • System.DirectoryServices.2.0.0.0.Nullness.Generated.xml
            • 78AE4555.bin
          • System.DirectoryServices.4.0.0.0.Nullness.Generated.xml
            • 494E7693.bin
          • System.DirectoryServices.Protocols.2.0.0.0.Nullness.Generated.xml
            • 6EFB7AB5.bin
          • System.DirectoryServices.Protocols.4.0.0.0.Nullness.Generated.xml
            • CFA46BF3.bin
          • System.DirectoryServices.Protocols.xml
            • 072F5742.bin
            • A1B5E32C.bin
          • System.DirectoryServices.xml
            • 14397267.bin
            • 796A6F49.bin
          • System.Drawing.2.0.0.0.Contracts.xml
            • AF2FFA85.bin
          • System.Drawing.2.0.0.0.Nullness.Generated.xml
            • 93BFA0F5.bin
          • System.Drawing.2.0.0.0.Pure.xml
            • 54741236.bin
          • System.Drawing.4.0.0.0.Contracts.xml
            • 90ED1C03.bin
          • System.Drawing.4.0.0.0.Nullness.Generated.xml
            • 283CCF33.bin
          • System.Drawing.4.0.0.0.Pure.xml
            • 07B8A9F0.bin
          • System.Drawing.Design.2.0.0.0.Nullness.Generated.xml
            • CB20AA15.bin
          • System.Drawing.Design.4.0.0.0.Nullness.Generated.xml
            • EFA69853.bin
          • System.Drawing.Design.xml
            • 7000BF52.bin
            • E232227C.bin
          • System.Drawing.xml
            • 2F425360.bin
            • 4AE71CCE.bin
          • System.Dynamic.4.0.0.0.Nullness.Generated.xml
            • 8CC52453.bin
          • System.EnterpriseServices.2.0.0.0.Nullness.Generated.xml
            • F38E6055.bin
          • System.EnterpriseServices.4.0.0.0.Nullness.Generated.xml
            • C42E9193.bin
          • System.EnterpriseServices.xml
            • 484CBB5B.bin
            • 5D2D9EF5.bin
          • System.I18n.xml
            • E767B348.bin
          • System.IdentityModel.3.0.0.0.Nullness.Generated.xml
            • 8D398F74.bin
          • System.IdentityModel.4.0.0.0.Nullness.Generated.xml
            • 912FB3D3.bin
          • System.IdentityModel.Selectors.3.0.0.0.Nullness.Generated.xml
            • 896B6974.bin
          • System.IdentityModel.Selectors.4.0.0.0.Nullness.Generated.xml
            • 8D618DD3.bin
          • System.IdentityModel.Selectors.xml
            • 17C23871.bin
            • 8E1D2D30.bin
          • System.IdentityModel.xml
            • 673E4F98.bin
            • FCECB5D9.bin
          • System.Management.4.0.0.0.Nullness.Generated.xml
            • 3E6A0593.bin
          • System.Management.xml
            • 8DDFA253.bin
          • System.Messaging.2.0.0.0.Nullness.Generated.xml
            • 2C9BE975.bin
          • System.Messaging.4.0.0.0.Nullness.Generated.xml
            • C11917B3.bin
          • System.Messaging.xml
            • 4EE26F6E.bin
            • 94C73840.bin
          • System.Nullness.Manual.xml
            • AC02D602.bin
          • System.Numerics.4.0.0.0.Nullness.Generated.xml
            • 0D729213.bin
          • System.Numerics.xml
            • F65D6778.bin
          • System.Runtime.Caching.4.0.0.0.Nullness.Generated.xml
            • 8BB7FA53.bin
          • System.Runtime.Caching.xml
            • 6E34C19B.bin
          • System.Runtime.DurableInstancing.4.0.0.0.Nullness.Generated.xml
            • 94C6B993.bin
          • System.Runtime.Remoting.2.0.0.0.Nullness.Generated.xml
            • 357DCF15.bin
          • System.Runtime.Remoting.4.0.0.0.Nullness.Generated.xml
            • 5A03BD53.bin
          • System.Runtime.Remoting.xml
            • 99D48EF3.bin
            • F93434DD.bin
          • System.Runtime.Serialization.3.0.0.0.Nullness.Generated.xml
            • 65D50AD4.bin
          • System.Runtime.Serialization.4.0.0.0.Nullness.Generated.xml
            • 4774B3B3.bin
          • System.Runtime.Serialization.Attributes.xml
            • E749FA69.bin
          • System.Runtime.Serialization.Formatters.Soap.2.0.0.0.Contracts.xml
            • 6A729305.bin
          • System.Runtime.Serialization.Formatters.Soap.2.0.0.0.Nullness.Generated.xml
            • 64B5C975.bin
          • System.Runtime.Serialization.Formatters.Soap.4.0.0.0.Contracts.xml
            • 4C2FB483.bin
          • System.Runtime.Serialization.Formatters.Soap.4.0.0.0.Nullness.Generated.xml
            • F932F7B3.bin
          • System.Runtime.Serialization.Formatters.Soap.xml
            • AC344D82.bin
            • FD932A2C.bin
          • System.Runtime.Serialization.xml
            • 014E8BDC.bin
            • F0B1191D.bin
          • System.Security.2.0.0.0.Contracts.xml
            • 7E44A425.bin
          • System.Security.2.0.0.0.Nullness.Generated.xml
            • 25CDEC55.bin
          • System.Security.2.0.0.0.Pure.xml
            • 895D4F56.bin
          • System.Security.4.0.0.0.Contracts.xml
            • 203E41A3.bin
          • System.Security.4.0.0.0.Nullness.Generated.xml
            • F66E1D93.bin
          • System.Security.4.0.0.0.Pure.xml
            • 3CA1E610.bin
          • System.Security.xml
            • 07099898.bin
            • 55841E76.bin
          • System.ServiceModel.3.0.0.0.Nullness.Generated.xml
            • F3859074.bin
          • System.ServiceModel.4.0.0.0.Nullness.Generated.xml
            • F77BB4D3.bin
          • System.ServiceModel.Activation.4.0.0.0.Nullness.Generated.xml
            • 98DDA2B3.bin
          • System.ServiceModel.Activation.xml
            • B91280C8.bin
          • System.ServiceModel.Activities.4.0.0.0.Nullness.Generated.xml
            • 7FF57E53.bin
          • System.ServiceModel.Activities.xml
            • AB91D397.bin
          • System.ServiceModel.Web.3.5.0.0.Nullness.Generated.xml
            • B061E091.bin
          • System.ServiceModel.Web.4.0.0.0.Nullness.Generated.xml
            • 3A483B53.bin
          • System.ServiceModel.Web.xml
            • 4B4A489F.bin
            • AFCF614C.bin
          • System.ServiceModel.xml
            • 263DB992.bin
            • BE8B8173.bin
          • System.ServiceProcess.2.0.0.0.Nullness.Generated.xml
            • 64FAEAD5.bin
          • System.ServiceProcess.4.0.0.0.Nullness.Generated.xml
            • 359B1C13.bin
          • System.ServiceProcess.xml
            • 2335E116.bin
            • B46FDC38.bin
          • System.Transactions.2.0.0.0.Nullness.Generated.xml
            • 68818E55.bin
          • System.Transactions.4.0.0.0.Nullness.Generated.xml
            • 3921BF93.bin
          • System.Transactions.xml
            • 7D351899.bin
            • A0E212F7.bin
          • System.Web.2.0.0.0.Contracts.xml
            • BAEFDF05.bin
          • System.Web.2.0.0.0.Nullness.Generated.xml
            • B4E89575.bin
          • System.Web.2.0.0.0.Pure.xml
            • 931326B6.bin
          • System.Web.4.0.0.0.Contracts.xml
            • 9CAD0083.bin
          • System.Web.4.0.0.0.Nullness.Generated.xml
            • 4965C3B3.bin
          • System.Web.4.0.0.0.Pure.xml
            • 4657BE70.bin
          • System.Web.Abstractions.3.5.0.0.Nullness.Generated.xml
            • 06EACF11.bin
          • System.Web.Abstractions.xml
            • A00BB8E5.bin
            • CCA4F1B6.bin
          • System.Web.ApplicationServices.4.0.0.0.Nullness.Generated.xml
            • 3969B1B3.bin
          • System.Web.ApplicationServices.xml
            • 331D36EA.bin
          • System.Web.Attributes.xml
            • C91B0A69.bin
          • System.Web.DataVisualization.4.0.0.0.Nullness.Generated.xml
            • 01959F33.bin
          • System.Web.DataVisualization.xml
            • 8800EDF4.bin
          • System.Web.DynamicData.4.0.0.0.Nullness.Generated.xml
            • EB87AD13.bin
          • System.Web.DynamicData.xml
            • DC2CFBFB.bin
          • System.Web.Entity.4.0.0.0.Nullness.Generated.xml
            • F4A1E313.bin
          • System.Web.Entity.xml
            • A8FBC385.bin
          • System.Web.Extensions.3.5.0.0.Nullness.Generated.xml
            • E9EAAC91.bin
          • System.Web.Extensions.4.0.0.0.Nullness.Generated.xml
            • 73D10753.bin
          • System.Web.Extensions.xml
            • 1594D3F4.bin
            • F1886C67.bin
          • System.Web.Helpers.xml
            • 0E774D98.bin
          • System.Web.I18n.xml
            • DDDA67C8.bin
          • System.Web.Mvc.Annotations.xml
            • B5228072.bin
          • System.Web.Mvc.Attributes.xml
            • A9871169.bin
          • System.Web.Mvc.I18n.xml
            • 3B8D2EC8.bin
          • System.Web.Mvc.Nullness.Manual.xml
            • 66942182.bin
          • System.Web.Mvc.xml
            • 7767440B.bin
            • C90B51CA.bin
          • System.Web.RegularExpressions.xml
            • B6E517C5.bin
            • CD932B2B.bin
          • System.Web.Routing.3.5.0.0.Nullness.Generated.xml
            • 71E5DC71.bin
          • System.Web.Routing.xml
            • 54275CA2.bin
            • D75C6BD1.bin
          • System.Web.Services.2.0.0.0.Nullness.Generated.xml
            • 5FB93F55.bin
          • System.Web.Services.4.0.0.0.Nullness.Generated.xml
            • 30597093.bin
          • System.Web.Services.Attributes.xml
            • 336EB089.bin
          • System.Web.Services.xml
            • 057956D0.bin
            • 357F9EBE.bin
          • System.Web.WebPages.Annotations.xml
            • E6592D12.bin
          • System.Web.WebPages.Attributes.xml
            • 2AF04289.bin
          • System.Web.WebPages.xml
            • 0190AFDD.bin
          • System.Web.xml
            • 03E9D35E.bin
            • C4EB8CF0.bin
          • System.Windows.Forms.2.0.0.0.Contracts.xml
            • 28E48E05.bin
          • System.Windows.Forms.2.0.0.0.Nullness.Generated.xml
            • 4E922475.bin
          • System.Windows.Forms.2.0.0.0.Pure.xml
            • 4A9E75B6.bin
          • System.Windows.Forms.4.0.0.0.Contracts.xml
            • 0AA1AF83.bin
          • System.Windows.Forms.4.0.0.0.Nullness.Generated.xml
            • E30F52B3.bin
          • System.Windows.Forms.4.0.0.0.Pure.xml
            • FDE30D70.bin
          • System.Windows.Forms.I18n.xml
            • 4286B6C8.bin
          • System.Windows.Forms.Manual.xml
            • 4EEF7F3C.bin
          • System.Windows.Forms.xml
            • 628A07B4.bin
            • 82C195DA.bin
          • System.Workflow.Activities.4.0.0.0.Nullness.Generated.xml
            • 95C13873.bin
          • System.Workflow.Activities.xml
            • FB17DE96.bin
          • System.Workflow.ComponentModel.4.0.0.0.Nullness.Generated.xml
            • 43C7AB93.bin
          • System.Workflow.ComponentModel.xml
            • 8A0F9E9D.bin
          • System.Workflow.Runtime.4.0.0.0.Nullness.Generated.xml
            • 5F2A0F93.bin
          • System.Workflow.Runtime.xml
            • 32431EC1.bin
          • System.WorkflowServices.4.0.0.0.Nullness.Generated.xml
            • DC2BE493.bin
          • System.WorkflowServices.xml
            • 8E65A1DD.bin
          • System.Xaml.4.0.0.0.Nullness.Generated.xml
            • A8037753.bin
          • System.Xaml.Hosting.4.0.0.0.Nullness.Generated.xml
            • 66496553.bin
          • System.Xaml.Hosting.xml
            • F261D856.bin
          • System.Xaml.xml
            • C4D1BFD8.bin
          • System.Xml.2.0.0.0.Contracts.xml
            • 1CF390E5.bin
          • System.Xml.2.0.0.0.Nullness.Generated.xml
            • B911D315.bin
          • System.Xml.2.0.0.0.Pure.xml
            • BEB7E496.bin
          • System.Xml.4.0.0.0.Contracts.xml
            • 53D95363.bin
          • System.Xml.4.0.0.0.Nullness.Generated.xml
            • DD97C153.bin
          • System.Xml.4.0.0.0.Pure.xml
            • 5A1C7B50.bin
          • System.Xml.Attributes.xml
            • 09EED2C9.bin
          • System.Xml.I18n.xml
            • 8B551FA8.bin
          • System.Xml.Linq.3.5.0.0.Contracts.xml
            • 927AA021.bin
          • System.Xml.Linq.3.5.0.0.Nullness.Generated.xml
            • D8E168D1.bin
          • System.Xml.Linq.3.5.0.0.Pure.xml
            • 89D3BBD2.bin
          • System.Xml.Linq.4.0.0.0.Contracts.xml
            • 0FA00AA3.bin
          • System.Xml.Linq.4.0.0.0.Nullness.Generated.xml
            • 0EE20693.bin
          • System.Xml.Linq.4.0.0.0.Pure.xml
            • 9C820F10.bin
          • System.Xml.Linq.I18n.xml
            • A5756368.bin
          • System.Xml.Linq.xml
            • AD7A27CD.bin
            • BA52F0DE.bin
          • System.Xml.xml
            • 3B538D57.bin
            • 48B5EA79.bin
          • System.xml
            • 74BB9F68.bin
            • C3B3EEEE.bin
            • CA128980.bin
          • WindowsBase.3.0.0.0.Nullness.Generated.xml
            • 04FEF8F4.bin
          • WindowsBase.3.0.0.0.Pure.xml
            • BC4535F7.bin
          • WindowsBase.xml
            • 3DC9B440.bin
      • CodeFirstEntities.sln
      • CodeFirstEntities.suo
      • CodeFirstEntities
      • packages
    • CodeFirstServices
    • Dlls
    • MvcPortal
  • SourceCode-noexe.zip

namespace CodeFirstData.DBInteractions
{
    public class UnitOfWork : IUnitOfWork
    {
        private readonly IDBFactory _databaseFactory;
        private CodeFirstContext _dataContext;

        public UnitOfWork(IDBFactory databaseFactory)
        {
            this._databaseFactory = databaseFactory;
        }

        protected CodeFirstContext DataContext
        {
            get { return _dataContext ?? (_dataContext = _databaseFactory.Get()); }
        }

        public void Commit()
        {
            DataContext.Commit();
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect https://codeteddy.com/
India India
Akhil Mittal is two times Microsoft MVP (Most Valuable Professional) firstly awarded in 2016 and continued in 2017 in Visual Studio and Technologies category, C# Corner MVP since 2013, Code Project MVP since 2014, a blogger, author and likes to write/read technical articles, blogs, and books. Akhil is a technical architect and loves to work on complex business problems and cutting-edge technologies. He has an experience of around 15 years in developing, designing, and architecting enterprises level applications primarily in Microsoft Technologies. He has diverse experience in working on cutting-edge technologies that include Microsoft Stack, AI, Machine Learning, and Cloud computing. Akhil is an MCP (Microsoft Certified Professional) in Web Applications and Dot Net Framework.
Visit Akhil Mittal’s personal blog CodeTeddy (CodeTeddy ) for some good and informative articles. Following are some tech certifications that Akhil cleared,
• AZ-304: Microsoft Azure Architect Design.
• AZ-303: Microsoft Azure Architect Technologies.
• AZ-900: Microsoft Azure Fundamentals.
• Microsoft MCTS (70-528) Certified Programmer.
• Microsoft MCTS (70-536) Certified Programmer.
• Microsoft MCTS (70-515) Certified Programmer.

LinkedIn: https://www.linkedin.com/in/akhilmittal/
This is a Collaborative Group

779 members

Comments and Discussions