no dogma blog
no dogma blog
Blog Posts
Podcast
Web API Lambda Course
Polly Course
Photos
Contact
Support this Site
About
RSS
Light
Dark
Automatic
Posts
Complex model validation using Fluent Validation
Full source code is available here. A common problem is validating an object using a complicated set of rules. I started using the Fluent Validation package some time back, it is commonly used with MVC and Web API applications but can be used with in any scenario that requires validation.
Apr 10, 2015
#
Fluent Validation
,
Validators
Using JSON to store application preferences and configuration
Download full source code. Storing configuration preferences in the database is not a hard task. It usually involves storing the name of the preference, the value and the type in the database.
Apr 6, 2015
#
Entity Framework
,
JSON
Saving enums as strings with Entity Framework
In September 2018 I wrote a new post explaining how to store enums as ints or strings with Entity Framework Core. It is a nicer solution than the one presented here.
Nov 23, 2014
#
Entity Framework
,
Enum
CastleWindsor chained dependency
Source code is available here. I recently had a problem where I wanted an MVC controller to use constructor injection of specified dependency and have that dependency load another specified dependency using Windsor.
Sep 8, 2014
#
Dependency Injection
Entity Framework lazy loading vs explicit loading and the generated SQL
Download the source code here. If you are using lazy loading with Entity Framework you should check that queries to the database are working as expected. A lazy load call to something like customer.
Aug 13, 2014
#
Entity Framework
,
Explicit loading
,
Lazy loading
Adding ROWGUIDCOL to Entity Framework Code First using migrations
To add add a ROWGUIDCOL to a unique identifier in a table using code first you have to use code migrations. Below is the snippet you need. I haven’t covered how to perform a migration because there are plenty of articles available.
Jul 29, 2014
#
Entity Framework
,
Migrations
Making a column sparse with Entity Framework Migrations
I have a database built off code first models, but I want to set some of the columns to sparse. There isn’t a way to this with the fluent api or through annotations.
Jul 24, 2014
#
Entity Framework
,
Migrations
Altering the ASP NET MVC model with an ActionFilter
Full source code here. Action filters are executed before and/or after the execution of an action method, they can be used to modify how an action executes or to perform a separate task, such as authorization or logging.
Jan 11, 2014
#
ActionFilter
,
ASP.NET MVC
,
AspNet
Skipping ActionFilters in ASP.NET MVC
Full source code here. In the previous post I showed how you can use an action filter to execute code both before and after an action method and how to apply the filter globally.
Jan 11, 2014
#
ActionFilter
,
ASP.NET MVC
,
AspNet
Serializing a stack to XML in C#
Serializing a class to XML in C# is straightforward; most collections can be easily serialized also. Something like the following will work in most scenarios - 1public string GetSerializedString<T>(T objectToSerialize) 2{ 3 var serializer = new XmlSerializer(typeof(T)); 4 TextWriter textWriter = new StringWriter(); 5 6 var xmlWriter = XmlWriter.
Jan 6, 2014
#
Serialization
«
»
Cite
×