Automapper give you a big leverage when it’s the time to take value from one object into an other object. Sometime, value must not be transferred. This can be the case for class that has not the property or for class that has some logic that will do the proper instanciation later. Automapper give the property Ignore which tell the mapper to not...
Filed in: Automapper
The problem with the error “Validation failed for one or more entities. See ‘EntityValidationErrors’ property for more details.” is that you cannot go inside it. In fact, you need to cast this one into DbEntityValidationException to be able to see inner errors. To see the exception details, you need to open the watch window,...
I have several example in this website that include with a string the property when it’s a property inside a collection of my main entity. Here is one example: return DatabaseContext .SetOwnable<Workout>() .Include(x => x.Sessions) .Include("Sessions.WorkoutSessionExercises") ...
The idea to create an Html Extension like ActionLink to create link only if the user has the authorization can be very helpful. The goal here is to display the link only if the action allow the user to execute the action. This way, every user will see link to action that it belong to. On the other hand, people with the access to these actions will see...
Filed in: ASP.MVC
If you are using Web Api of .Net 4.5 framework and want to have the same behavior of Asp.Net MVC which let you have global authorization set to every http request, than you need to configure your website differently. In Asp.Net you would add a new filter to the FilterConfig file. public static void RegisterGlobalFilters(GlobalFilterCollection filters) { ...
Filed in: ASP.MVC, WebServices
Web Api controller are instantied by Asp.Net MVC framework and by default, the parameter less constructor is called. If you want to instantiate your class with your IoC, like Microsoft Unity, you will have to customize the instantiation of those Web Api Controller. The customized instanciator is called a Dependency Resolver and can be configured in...
It’s rare that I wrote something in PHP but since I have worked with Paypal with PHP in 2009, it will be simpler for me to show you how it works with this language. The same process can be apply for your .Net website. In fact, most steps are within Paypal website and interact with plain Html. Paypal offers many ways to use their system for transaction....
Filed in: PHP
You can use the default Html Helper to have a text url. This is most of the time sufficient but when came the scenario that you want an image to be a link, you are alone. You can create every time a link that will contain an image. But, with Asp.Net MVC, one nicest way to do it would be with an Html Extension. The main reason is that you won’t...
Filed in: ASP.MVC
If you are using Entity Framework with a repository layer which has the basic method like Get, Update, Insert (or Add) and Delete you are already in a good position. But what if you want to update a single property without having to load the whole entity from the database? If you have only the primary key (id) of your entity and the value of the property...
It’s always a good idea to be able to see what’s happening behind when you are using ORM, like Entity Framework. If you have the possibility to have the full blow Sql Server with tools, than you have the Sql Profiler that can tell you every queries executed. Unfortunately, if you are using the Sql Express Edition, you won’t have the...
wordpress themplates