Archives
-
I’m An Old School Guy
Yes, in 2014, I am still talking about ASP.NET Web Forms instead of MVC, Web API, SignalR and OWIN!
-
Client Callbacks In Action Part 1: Auto Completing Text Boxes
I have talked about client callbacks in the past, and even provided a general-purpose control for invoking code on the server-side. This time, I will provide two more examples:
-
Developing Windows Store Apps with HTML5 and JavaScript Review
-
Sending Messages to SignalR Hubs from the Outside
You are by now probably familiarized with SignalR, Microsoft’s API for real-time web functionality. This is, in my opinion, one of the greatest products Microsoft has released in recent time.
-
Hijacking ASP.NET Sessions
So, you want to be able to access other user’s session state from the session id, right? Well, I don’t know if you should, but you definitely can do that!
-
Tracing Entity Framework Code First Calls
Microsoft has published, some time ago, a set of Entity Framework providers, for adding caching and tracing capabilities to Entity Framework. One of these providers, tracing, is now available as a NuGet package. This offers an interesting functionality: the ability to see all SQL that Entity Framework is sending to the database, and its results. The provider works with “classic” Entity Framework as well as with Code First, and I am going to focus on the latter and show you how you can use it.
-
Unity Index
Updated on October 27th
-
Entity Framework Pitfalls: Null Navigation Properties
What if, after you load an entity, you have a reference property for another entity that is null yet you are sure that it points to a valid record? This will likely be because of one of two things:
-
Entity Framework Pitfalls: Deleting Detached Entities With Required References
It is common practice in O/RMs to delete an entity without actually loading id, just by knowing its id. This saves one SELECT and is great for performance. For example, using Entity Framework Code First:
-
Entity Framework Pitfalls: Non Nullable Columns in Table Per Class Hierarchy Inheritance
When you use the Table Per Class Hierarchy inheritance mapping pattern (Single Table Inheritance in Martin Fowler’s terminology), all properties of derived classes should map to nullable columns in the database. This should be pretty obvious: because all derived (concrete) entities will be stored in the same table, and each will have its own properties, that will be stored as columns in the same table. Each instance of a given entity will be stored as a record in this table, and of course each entity knows nothing about the properties of other entities.
-
Entity Framework Code First One to One With Cascade Delete
I recently had to figure how to achieve cascade deletes on a one to one mapping. The solution, I soon found out, required fluent configuration.
-
Entity Framework Pitfalls: Cannot Return Complex Types From SQL Queries
Clarified: thanks, Diego!
-
Entity Framework Pitfalls Index
Updated on January 16th
-
Entity Framework Pitfalls: Concrete Table Inheritance and Identity Keys
When using the Concrete Table Inheritance / Table Per Concrete Type pattern for mapping entity inheritances, you cannot use IDENTITYs as primary keys. It is easy to understand why: because each entity of a concrete type is stored in its own table, and if these tables would be using IDENTITYs for generating the primary key, if we would issue a query on their base class looking for a record by its primary key, Entity Framework would generate lots of UNIONs, one for each table, where only one could possibly return a record.
-
Entity Framework Code First Table Splitting
Since Entity Framework does not support lazy scalar properties, only lazy references and collections, in order to avoid automatic loading of columns with large contents – BLOBs or CLOBs – we can use a technique called table splitting. In a nutshell, this means using multiple entities to store the columns of a table, say, one for the core, and another for the heavy columns.
-
Entity Framework Pitfalls: Validation Does Not Load Lazy Properties
In a nutshell: Entity Framework Code First (EFCF) validation does not load lazy properties. If any of these properties is marked as required, and it is not loaded, a validation error will occur.
-
Mapping Non-Public Members With Entity Framework Code First
This is a common request, and really makes sense; we need to use LINQ expressions and a bit of reflection magic. First, an helper function for returning an expression that points to a member:
-
Caching LINQ Queries
Some days ago I wrote a post on comparing LINQ expressions where I shared my discoveries and general discontent on how difficult it is do right. The reason I was looking into it was because I wanted to write a LINQ query caching mechanism.
-
Five Years of Blogging
Five years have passed since my first post, which occurred just after the creation of this blog. It was my first “social” experience on the Internet, and I learned a lot from it.
-
Instant StyleCop Code Analysis How-to Review
-
Profiling Entity Framework Code First With MiniProfiler
Updated: thanks, RichardD!
-
My View on ASP.NET Web Forms versus MVC
A lot has been said on Web Forms and MVC, but since I was recently asked about my opinion on the subject, here it is.
-
Pluggable Rules for Entity Framework Code First
Suppose you want a system that lets you plug custom validation rules on your Entity Framework context. The rules would control whether an entity can be saved, updated or deleted, and would be implemented in plain .NET. Yes, I know I already talked about plugable validation in Entity Framework Code First, but this is a different approach.
-
Unity – Part 5: Injecting Values
This is the fifth post on Unity. You can find the introductory post here, the second post, on dependency injection here, a third one on Aspect Oriented Programming (AOP) here and the latest so far, on writing custom extensions, here. This time we will talk about injecting simple values.
-
NHibernate Conventions
It seems that nowadays everyone loves conventions! Not the ones that you go to, but the ones that you use, that is! It just happens that NHibernate also supports conventions, and we’ll see exactly how.
-
Dynamic LINQ Extension Method
Remember those old posts on Dynamic LINQ? You are probably aware that Microsoft has made its implementation available as a Nuget package, but, like I said, you already have it in your machine, hidden inside the System.Web.Extensions assembly.
-
Comparing LINQ Expressions
I recently came upon this problem: how to calculate a hash from a LINQ expression so that I can safely compare two expressions for equality? I had naively assumed that the Expression class – and their descendants – would have implemented GetHashCode in an appropriate way, so as to make developer’s lifes easier, but unfortunately Microsoft thought otherwise.
-
Entity Framework Metadata
Sometimes it is useful to know something about the physical storage of a code first model. Maybe it’s for SQL reporting or for any other matter, I sometimes have the need to look up the table name where an entity is stored or the column that holds some relation.
-
Unity – Part 4: Extensions
Another long overdue post on Unity. See the first here for an introduction, the second here for dependency injection and the third here for AOP with Unity.
-
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.
-
Querying Entity Framework Code First Inheritance
This is a short post to complement my previous one on Entity Framework Code First Inheritance: how to query for a specific class. The options are:
-
Visual Studio 2012 and .NET 4.5 Expert Development Cookbook Review
-
Entity Framework Code First Inheritance
Another post for self reference, this time, how to map inheritance strategies with Entity Framework Code First.
-
Entity Framework Code First Relations
This post is more for self-reference than anything else. Basically, I tend to forget some options for mapping relations with Entity Framework Code First, so I wrote this. If in doing so it helps someone, even better!
-
Unity – Part 3: Aspect Oriented Programming
-
Unity – Part 2: Dependency Injection
Second part of my series on Unity. For an introduction, read the first post.
-
Unity - Part 1: Introduction
Updated: ContainerControlled instead of ExternallyControlled in the bullet list of lifetime managers. Thanks, Ross Smith!
-
NHibernate Pitfalls: Collections of Elements and Inverse
This is part of a series of posts about NHibernate Pitfalls. See the entire collection here.
-
Extended ASP.NET Button Control
I once had the need to have a button control that would change its look depending on a theme, for example, it would render either as regular button, an image or a link. Of course, the only way I had to achieve this was by manually swapping the Button control for a ImageButton or a LinkButton, which wasn’t really a solution, so I started to think of a control that could do the trick… and here it is!
-
ASP.NET Web Forms Extensibility: Handlers
In the .NET world, all HTTP requests, whether they be for web services (XML, WCF, Web API), pages (Web Forms and MVC), etc, are processed by a handler. Basically, a handler is a particular implementation of the IHttpHandler interface, and requests are routed to a particular handler class by one of four ways:
-
NHibernate Pitfalls: DateTime Type Loses Milliseconds
This is part of a series of posts about NHibernate Pitfalls. See the entire collection here.
-
NHibernate Pitfalls: Take and Where Order in LINQ Queries
This is part of a series of posts about NHibernate Pitfalls. See the entire collection here.
-
Custom LINQ Extensions for NHibernate
With extensibility virtually everywhere, NHibernate is nice to work with! Consider, for example, a need to call a database-specific function in a LINQ query – a typical request.
-
NHibernate Pitfalls: Non Nullable Columns in Table Per Class Hierarchy Inheritance
This is part of a series of posts about NHibernate Pitfalls. See the entire collection here.
-
Strongly Typed Routes for ASP.NET MVC
OK, I know there are already a number of these, but since I didn’t actually know any, I wrote my own library.
-
Soft Deletes With NHibernate, Part II
After my previous post, Adam Bar suggested that setting an SQL Delete command might be a better idea, I actually agree with him, so I decided to post an alternative solution.
-
Attaching Disconnected Entities in NHibernate Without Going to the Database
Because the SaveOrUpdateCopy method of ISession is marked as obsolete, we no longer have an API method that allows us to attach a disconnected entity (meaning: coming from a session that no longer exists) to a new session without going to the database, something that Merge, Lock, Refresh all do. Sometimes this is not desirable.
-
Soft Deletes With NHibernate
Updated: thanks, Adam
-
NHibernate Pitfalls: Making Changes to the Configuration After the Session Factory Is Built
This is part of a series of posts about NHibernate Pitfalls. See the entire collection here.
-
My All Time Favorite Posts
Since this blog started, back in 2008, I wrote a lot of posts. I’d say some are still up to date. I picked a few of them, those I’m more proud of, in no particular order.
-
NHibernate Pitfalls: Integrating NHibernate Validator
This is part of a series of posts about NHibernate Pitfalls. See the entire collection here.
-
NHibernate Pitfalls: Batch Loading
This is part of a series of posts about NHibernate Pitfalls. See the entire collection here.
-
Blog em Português
(Portuguese only, sorry!)
-
NHibernate Pitfalls: Identity Identifiers
This is part of a series of posts about NHibernate Pitfalls. See the entire collection here.
-
NHibernate Pitfalls: Schema Auto Action
This is part of a series of posts about NHibernate Pitfalls. See the entire collection here.
-
NHibernate Pitfalls: Manually Assigned Identifiers
This is part of a series of posts about NHibernate Pitfalls. See the entire collection here.
-
NHibernate Extensibility Index
Updated on January 19th
-
ASP.NET Extensibility Index
Updated on July 10th.
-
NHibernate Pitfalls: Sets and Hash Codes
This is part of a series of posts about NHibernate Pitfalls. See the entire collection here.
-
ASP.NET Web Forms Extensibility: URL Mapping
A long time before ASP.NET Routing came along, ASP.NET already offered a similar functionality: it was called URL mapping.
-
ASP.NET DropDownList With Groups
A long time ago I submitted a request to the ASP.NET team for having the standard DropDownList support HTML’s optgroup tag: http://aspnet.codeplex.com/workitem/10318. For those of you not familiar with this tag – that has been around for quite some time, by the way –, it allows for something like this:
-
NHibernate Pitfalls: Flush Mode
This is part of a series of posts about NHibernate Pitfalls. See the entire collection here.
-
ASP.NET Web Forms Extensibility: Tag Mapping
There may be times when you want a particular setting applied to all controls of a given type, in all pages. Or you want to debug this control, but you don’t have access to it’s source code. Or you want to change its behavior. For that, you can use tag mapping, and I have given an example before.
-
ASP.NET Image Control With Fallback URL
What happens when the URL that your image is pointing to does not exist or cannot be reached? Well, all browsers I know of resort to displaying something like:
-
ASP.NET Web Forms Extensibility: Modules
Next in the series is modules. So, what is a module, and what does it do?