By Carlos Martinez.
The repository is useful when trying to separate the domain logic from the logic that retrieves the data and maps it in entity objects.
The repository is a small layer between the data source layer and the upper domain layers of the application. Gets the data from the data source and retrieves it to the upper layers. Also the repository contains the persistence logic of the domain objects. This logic separation has 3 benefits:
· The logic for web services and data are centralized
· It simplified the unit test.
· It provides a flexible architecture that can be adapted as the overall design of the application evolves.
By Daniel Ramirez.
An important thing through the Software Development Cycle is the feedback a developer gets during or after iteration. He/she gets all kinds of it, from internal things such as code, to all the way up to what’s shown to the end users.
Feedback is important
In any kind of work, I believe we should always look for some kind of feedback. Feedback does not necessarily means you have done things the wrong way, it can help you see how other people see your work, and lets you know if they understood correctly the idea behind it.
Feedback lets you know if things can be improved, motivates you to continue your work. If you get an email saying "Amazing work!"...
By: Alejandro Villarreal
I recently experienced one of the most puzzling issues I’ve dealt with: after I finished coding my project in Visual Studio 2010 I tried to build it but it failed, complaining of namespaces that didn’t exist (which means a bunch of types that weren’t declared and thus code that the compiler didn’t understand). This didn’t make sense because the assembly that contained those namespaces was still in the “References” part of my project, and I had used IntelliSense with the types it contained. So I knew for a fact that Visual Studio did know that the assembly was there, and was able to analyze it and use it.
But then why couldn’t I build my project? I tried removing a...
By Fernando Mendoza.
I’ve been using Fiddler a lot these days. To test how requests and responses go to and come back from the server, being HTML responses, SOAP responses or custom responses from web services.
One website I like a lot is StackOverflow; I use it to find answers when I’m stuck with a programming or configuration issue. I like this site, and even though they don’t have too many ads it still bothers me a bit. So one day I was thinking if it was possible to use Fiddler to modify the HTTP response from the StackOverflow server before it’s rendered by the browser.
Turns out it’s possible, Fiddler has something called Rules that allows you do that. Let’s see how to do that st...
By Alejandro Villarreal
A few months ago we developed a slightly complex service that made use of query notifications to keep an in-memory copy of some database tables. The service worked like a charm, it passed QA, UAT, and went into production, where it has been working ever since. Recently, however, our client had a vague suspicion that something weird was happening with it, but could not pinpoint exactly what, and they only felt like this after a couple of weeks of the service working just fine. Restarting the service dissipated whatever problem the service appeared to be having, so we all lived with that for a while… until they found actual evidence that the service was not respondi...
By Carlos MartinezDependency Injection is a form of Inversion of control where the dependent objects are injected into a class, instead of creating an instance.
The usual way to implement this pattern is using an object container and plain objects. Each container injects the entire requested objects based on a previous configuration.
A new interface is available in MVC 3, called “IDependencyResolver”. This interface enabled service location by providing these 2 methods:
· GetService(Type serviceType)
· GetServices(Type serviceType)
While in MVC 2 a custom ControllerFactory has to be created (and specified in the application class), in MVC 3 all it takes is to specify a...
By Carlos MartinezThe System.Web.Mvc namespace contains a class named DefaultModelBinder, the application object in MVC uses an instance of this class in order to binding all the values inside a post to a given model so it can be passed to an action. For normal scenarios no code is needed for these purposes.
When needed, a custom binder can be used in order to implement complex binding logic to a specific action or type. This new custom binder should implement the IModelBinder interface; this binder could be specified in the parameter definition of the post action for example:
[HttpPost] public ActionResult Index([ModelBinder(typeof(CustomModelBinder))] CustomModel model)
By Carlos Martinez
A common (and very recommended) practice when working with model validation in MVC3 is to decorate the model that will be sent to the view with validation attributes. In order to do this MVC3 has several validation attributes ready to use for this scenarios such as:
An easy way to implement custom validation is to create attributes that inherits the ValidationAttribute
class and add logic to the IsValid Method.
Adding code in this point will add server validations to the model (once the values are filled in the model throu a ModelBinder this vali...
By David E.
Sometimes DataTable objects are used as data sources for some of the controls in your application, either desktop or web application. At times the DataTable objects contain more items than needed, and you need to apply a filter for those records. An easy way to apply this filter can be by the AsEnumerable of the datatable object. This method is available from. net framework 3.5.
Below is a simple example:
//Get the dataset from Database
DataSet ds = GetDataSetFromDataLayer();
//Verify the DS
if (ds != null && ds.Tables.Count > 0)
//Get the required table
By David E.
The following guide was the created installing MSQueue and configuring a WCF using a Windows 7 OS.
1. Verify IIS is installed on the server machine where the WCF is going to be hosted.
2. Install MS Queue by following the instructions specified on this link:
3. Install or verify the following Windows Features :
4. Verify the following services are running:
a. Message Queuing
b. Net.Msmq Listener Adapter
c. Windows Process Activation Service
5. Create a Web application inside IIS. For this example, the application name used is FGMQService. The ap...