repository-pattern

C#: Repository Methods vs. Extending IQueryable

Hello, I have repositories (e.g. ContactRepository, UserRepository and so forth) which encapsulate data access to the domain model. When I was looking at searching for data, e.g. finding a contact whose first name starts with XYZ a contact whose birthday is after 1960 (etc), I started implementing repository methods such as Firs...

Repository or dependency injection library for Azure

Can anyone point me at a decent repository or dependency injection library for any of the variations of Azure data services? I'm looking for quicker ways to bring applications to market and would like a library that allows (even more) minimal coding to persist and retrieve entities to the cloud. Preferably libraries that provide source...

Do we need to Re-create Model Classes while using the Repository Pattern

Hi I'm using the LinqtoSQL for a WPF M-V-VM application, as I might want to change from LinqtoSql to something else in the future, like Entity framework or Subsonic etc, thus I found repository pattern to be helpful, My question is how do I create the model classes, suppose I have an table in the database, I understand that I cannot u...

With Repository pattern, what is the most effective way of updating records?

I am implementing Repository Pattern with ADO.NET entity framework. I see that updating records is relatively more complicated than just adding or removing from the database. See below the Update statement and add statement for your judgment. I was wondering if there is any way that I can update the record without having to retreive...

Using Stored Procedures with Linq To Sql which have Additional Parameters

I have a very big problem and can't seem to find anybody else on the internet that has my problem. I sure hope StackOverflow can help me... I am writing an ASP.NET MVC application and I'm using the Repository concept with Linq To Sql as my data store. Everything is working great in regards to selecting rows from views. And trapping very...

ASP.NET MVC with LINQ to SQL: How to implement Authorization to Entities in the Repository?

With Domain Driven Design in mind, how would you implement user Authorization in a repository? Specifically, how would you restrict what data you can see by the user provided login? Lets say we have an e-commerce Mall that stores products, where only some products are maintained by any given store manager. In this case, not all produc...

Repository can have DTO?

Hi, I have a DTO and entity e.g PersonDTO and Person. I have created a aaplication using DDD in which i have PersionApplciation which takes DTO as input and call the PersonService internally. In PersonService i get the instance of Person using PersonFactory(Only populating from DTO and setting values to Person entity).After getting insta...

Using MVC and fluent Nhibernate, how do I validate unique fields on my ViewModel before I bind them to my Domain Object and Save them?

I have a website where I allow users to create new Part records. I'm trying to figure out the best way to validate specific fields for uniqueness. I want to make sure that somebody doesn't try to add a Part with PartNumber 1234 if that PartNumber already exists on a different Part. The Web Application is using Asp.net MVC with fluen...

How does SelectByKey work in the Repository Pattern?

Hi, I'm implementing the repository pattern found here Implementing Repository Pattern With Entity Framework One of the methods he has is SelectByKey. In the comment called Key field impementation by [email protected], there was a suggestion to make it a little more generic of an implementation: I would like to add a simple mechani...

"Session is Closed!" - NHibernate

This is in a web application environment: An initial request is able to successfully complete, however any additional requests return a "Session is Closed" response from the NHibernate framework. I'm using a HttpModule approach with the following code: public class MyHttpModule : IHttpModule { public void Init(HttpApplication conte...

Question about repository pattern

Is this a good or bad idea? public interface IRepository<T> { ... IList<T> Get(Func<T, bool> predicate) ... } I mean - it seems really powerful addition and i could implement it too (at least - to some level) but my guts tells me it's kind a wrong. Could anyone enlighten me? ...

Getting started with TDD and DDD

I've just finished reading "Domain-driven design: tackling complexity in the heart of software" by Eric Evans and I'm attempting to write my first domain-centric application (in C#). The application will be used by our helpdesk to track the allocation of computers to users. I've sketched a simple class diagram to reflect part of the do...

How to implement CQS with in memory changes?

Having Watched this video by Greg Yound on DDD http://www.infoq.com/interviews/greg-young-ddd I was wondering how you could implement Command-Query Separation (CQS) with DDD when you have in memory changes? With CQS you have two repositories, one for commands, one for queries. As well as two object groups, command objects and query o...

Linq2Sql generated classes able to put into a separate project?

Can anyone tell me if its possible to extract the linq2sql generated classes into a separate project in c#? - I presume I can just create the files and then copy them to a new project and add a reference to my Data project? The problem I have is that I have my UI, Service Layer and Data layer... Currently the data layer also has the ge...

Entity Framework and repository pattern problem.

Hi! I am using generic repository pattern with methods: private ObjectQuery<T> ObjectQueryList() { var list = CamelTrapEntities.CreateQuery<T>(EntitySetName); return list; } public IQueryable<T> List() { return ObjectQueryList(); } Metod List() returns IQueryable<T>, becase IQ...

How to organize my classes/interfaces using repository pattern and factory method pattern?

I am creating a sample, application to understand repository and factory method patterns together, because will use in a bigger project. What i want to achieve is be able to make the website work with different ORM tools. For example the website will have LINQ to SQL and Ado entity frame work classes implemented then using the factory ...

Inheritance/design issue with domain entities that can be individual or combined

I have completely confused myself trying to design the necessary interfaces and abstracts to accomplish loading of domain entities that can be used by themselves as well as combined into an aggregate. Wow. That was a buzzword mouthful. Essentially, I have two objects that I would like to have base-type "load" functionality, but when t...

Fluent NHibernate and the repository pattern

Is this a good guide if I want to implement the repository pattern in my asp.net mvc application? ...

How to use the repository pattern correctly?

Hi I am wondering how should I be grouping my repositories? Like from the examples I seen on the asp.net mvc and in my books they basically use one repository per database table. But that seems like a lot of repositories leading you to have to call up many repositories later on for mocking and stuff. So I am guessing I should group the...

How to solve this generic with repository pattern problem?

I had this code from a previous question, but its not compiling: public interface IEntity { // Common to all Data Objects } public interface ICustomer : IEntity { // Specific data for a customer } public interface IRepository<T, TID> : IDisposable where T : IEntity { T Get(TID key); IList<T> GetAll(); void S...