Archives
-
The State of Entity Framework and NHibernate
Some time ago, I compared NHibernate and Entity Framework. It was from a very technical point of view, and I think it is still up to date. Today, I want to talk about the current state of things, from a less technical stand.
-
Intercepting LINQ Queries
A common request when working with LINQ queries (Entity Framework, NHibernate, etc) is the ability to intercept them, that is, inspect an existing query and possibly modify something in it. This is not extremely difficult to do “by hand”, but Microsoft has a nice class called ExpressionVisitor which makes the job easier. It basically has virtual methods that get called whenever the class visits each expression contained in a greater expression, which may come from a query (the IQueryable interface exposes the underlying Expression in its Expression property). The virtual methods even allow returning a replacement for each expression found, the only problem is that you must subclass ExpressionVisitor to make even the slightest change, so I wrote my own class, which exposes all node traversal as events, one event for each kind of expression, where you can return an alternative expression, thus changing the original query. Here is the code for it:
-
Entity Framework Code First Fluent Validation
Back to Entity Framework Code First (EFCF) validation. On my previous post I mentioned that EFCF did not support fluent validation. While this is true, it isn’t too hard to implement one such mechanism, which is exactly why I am writing this!
-
Entity Framework Code First Validation
Most persistence frameworks implement some kind of custom validation of entities before they are sent to the database. By custom I mean something more than just “is not null”, “has XX characters”, etc. This typically includes individual properties as well as validation of the entity as a whole – for example, checking that a property’s value is valid when used together with another property’s value.
-
Blogs Em Língua Portuguesa Sobre SharePoint
This post is in portuguese only, sorry!
-
Using the Enterprise Library 6 Configuration Console with Visual Studio 2012
You will have to download and run the Configuration Console from http://www.microsoft.com/en-us/download/details.aspx?id=38789, there is no NuGet package for it. After that, you will get a context menu for each project on the solution for editing the configuration:
-
Filter Collections Automatically With Entity Framework Code First
In some O/RMs, it is possible to specify automatic filters for entity collections such as one-to-many or many-to-many. These are applied automatically whenever these collections are being populated. Entity Framework does not offer one such mechanism, however, it is possible to implement it.