Repository Pattern with Entity Framework 4.1 and Parent/Child Relationships

The primary reason why I want to use this pattern is to avoid calling EF 4.1 specific data access operations from the domain. I’d rather call generic CRUD operations from a IRepository interface. This will make testing easier No it will not make your testing easier. You exposed IQueryable so your repository is not unit … Read more

using stored procedure in entity framework

You need to create a model class that contains all stored procedure properties like below. Also because Entity Framework model class needs primary key, you can create a fake key by using Guid. public class GetFunctionByID { [Key] public Guid? GetFunctionByID { get; set; } // All the other properties. } then register the GetFunctionByID … Read more

Repository Pattern Standardization of methods

I second the Fowler quote cited by oded. I want to point out that he said “collection-like” interface. How you implement the collection like interface is certainly up to you, but neither can nor should you try to hide the fact it represents a remote datasource. It therefore differs significantly from an in-memory collection, which … Read more

Configuring Ninject with Asp.Net MVC & Web Api

I have written some gists to help configure Ninject with MVC and Web Api. Simply include the file(s): https://gist.github.com/odytrice/5821087 (for MVC) https://gist.github.com/odytrice/5842010 (for WebApi) To add Bindings for concrete Types, Just put them in the Load() method of the MainModule. You can create as many modules as you like to keep bindings organized. but you’ll … Read more

Replacing a full ORM (JPA/Hibernate) by a lighter solution : Recommended patterns for load/save?

This kind of problem is typical when not using a real ORM, and there is no silver bullet. A simple design approach that worked for me for a (not very big ) webapp with iBatis (myBatis), is to use two layers for persistence: A dumb low-level layer: each table has its Java class (POJO or … Read more

Specification Pattern in Domain Driven Design

I think Specification pattern is not designed for query criteria. Actually, the whole concept of DDD is not, either. Consider CQRS if there are plethora of query requirements. Specification pattern helps develop ubiquitous language, I think it’s like kind of a DSL. It declares what to do rather than how to do it. For example, … Read more

Best way to implement Repository Pattern?

There’s also a good argument for a “none of the above” approach. The problem with generic repositories is that you’re making the assumption that all objects in your system will support all four CRUD operations: Create, Read, Update, Delete. But in complex systems, you’ll likely have objects that support only a few of the operations. … Read more

Repository and Unit of Work patterns – How to save changes

Repository can work without Unit Of Work, so it can also have Save method. public interface IRepository<T> { T Get(int id); void Add(T entity); void Update(T entity); void Remove(T entity); void Save(); } Unit Of Work is used when you have multiple repositories (may have different data context). It keeps track of all changes in … Read more

How to get primary key value with Entity Framework Core

I also faced with similar problem and found the following solution // Entity Framework Core public virtual int GetKey<T>(T entity) { var keyName = Context.Model.FindEntityType(typeof (T)).FindPrimaryKey().Properties .Select(x => x.Name).Single(); return (int)entity.GetType().GetProperty(keyName).GetValue(entity, null); }

Repository Pattern: how to Lazy Load? or, Should I split this Aggregate?

Am I misinterpreting the intent of the Repository pattern? I’m going to say “yeah”, but know that me and every person I’ve worked with has asked the same thing for the same reason… “You’re not thinking 4th dimensionally, Marty”. Let’s simplify it a little and stick with constructors instead of Create methods first: Editor e … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)