repository-pattern

using stored procedure in entity framework

点点圈 提交于 2019-11-26 02:22:10
问题 I am using asp.net mvc 5 and C# with Entity Framework... I have model and domain classes for function... now I need to use stored procedure.... which I am struggling at the movement. I am following code first existing database and I have stored procedure written there. My question is how I can call that stored procedure in my web application. Stored procedure: ALTER PROCEDURE [dbo].[GetFunctionByID]( @FunctionId INT ) AS BEGIN SELECT * FROM Functions As Fun WHERE Function_ID = @FunctionId END

How to implement Unit Of Work pattern with Dapper?

余生颓废 提交于 2019-11-26 01:58:41
问题 Currently, I am trying to use Dapper ORM with Unit Of Work + Repository Pattern. I want to use Unit of Work as opposed to a simple dapper Repository due to the fact that my insert and updates require a degree of transaction processing. I have been unable to find any useful examples as most seem to use Entity Framework and have leakage issue within the Unit of Work. Could someone please point me in the right direction? 回答1: This Git project is very helpful. I started from the same and did some

How are Spring Data repositories actually implemented?

假如想象 提交于 2019-11-26 01:49:08
问题 I have been working with Spring Data JPA repository in my project for some time and I know the below points: In the repository interfaces, we can add the methods like findByCustomerNameAndPhone() (assuming customerName and phone are fields in the domain object). Then, Spring provides the implementation by implementing the above repository interface methods at runtime (during the application run). I am interested on how this has been coded and I have looked at the Spring JPA source code & APIs

Method cannot be translated into a store expression

℡╲_俬逩灬. 提交于 2019-11-26 01:47:13
问题 I saw this code work with LINQ to SQL but when I use Entity Framework, it throws this error: LINQ to Entities does not recognize the method \'System.Linq.IQueryable\'1[MyProject.Models.CommunityFeatures] GetCommunityFeatures()\' method, and this method cannot be translated into a store expression.` The repository code is this: public IQueryable<Models.Estate> GetEstates() { return from e in entity.Estates let AllCommFeat = GetCommunityFeatures() let AllHomeFeat = GetHomeFeatures() select new

Entity Framework 4 CTP 4 / CTP 5 Generic Repository Pattern and Unit Testable

一曲冷凌霜 提交于 2019-11-26 01:12:54
问题 I\'m playing with the latest Entity Framework CTP 5 release and building a simple asp.net MVC blog where I just have two tables: Post and Comments. This is done entirely in POCO, I just need help on the DbContext part, where I need it to be unit testable (using IDbSet?) and I need a simple/generic repository pattern for add, update, delete, retrieval. Any help is appreciated. Thanks. 回答1: Start with you DbContext, create a new file called Database.cs: Database.cs public class Database :

Generic Repository With EF 4.1 what is the point

大兔子大兔子 提交于 2019-11-26 00:10:20
问题 As i dig deeper in to the DbContext, DbSet and associated interfaces, I am wondering why you would need to implement a separate \"Generic\" Repository around these implementations? It looks like DbContext and IDbSet do everything you need and include the \"Unit Of Work\" inside DbContext. Am I missing something here or does it seem people enjoy adding another layer of dependency for no reason. 回答1: You are actually right. DbContext is an implementation of the unit of work pattern and IDbSet

What&#39;s an Aggregate Root?

跟風遠走 提交于 2019-11-25 22:40:32
问题 I\'m trying to get my head around how to properly use the repository pattern. The central concept of an Aggregate Root keeps coming up. When searching both the web and Stack Overflow for help with what an aggregate root is, I keep finding discussions about them and dead links to pages that are supposed to contain base definitions. In the context of the repository pattern, what is an aggregate root? 回答1: In the context of the repository pattern, aggregate roots are the only objects your client

Method cannot be translated into a store expression

若如初见. 提交于 2019-11-25 21:46:54
I saw this code work with LINQ to SQL but when I use Entity Framework, it throws this error: LINQ to Entities does not recognize the method 'System.Linq.IQueryable'1[MyProject.Models.CommunityFeatures] GetCommunityFeatures()' method, and this method cannot be translated into a store expression.` The repository code is this: public IQueryable<Models.Estate> GetEstates() { return from e in entity.Estates let AllCommFeat = GetCommunityFeatures() let AllHomeFeat = GetHomeFeatures() select new Models.Estate { EstateId = e.EstateId, AllHomeFeatures = new LazyList<HomeFeatures>(AllHomeFeat),