Usually I access data with ORM like NHibernate or Entity Framework and resort to plain T-SQL only for reporting or manipulation of massive data, but yesterday I had to use some plain SQL to insert data in a table that has Geograpy column. Figure 1: A table with geography data If you use EF 5 [...]

Continue reading about Inserting a Geography data in Sql Server with plain C# SqlCommand

This is a common question for people that used NHibernate before using EF. The problem is, I have an object and I do not want to care about if this is a new object that needs to be added for the first time to the database, or it is an object that needs update or [...]

Continue reading about Using SaveOrUpdate in Entity Framework

The major pain when you switch from two similar tools (from NH to EF in this specific scenario) is that you need to learn again how to obtain the same results, but in a different way. Yesterday I was mapping a hierarcy of objects in Entity Framework, I’ve a scenario where Table Per Type was [...]

Continue reading about Entity Framework Code First and TPH Inheritance mapping

Today a colleague told me that he got a strange Entity Framework error Some part of your SQL statement is nested too deeply. Rewrite the query or break it up into smaller queries I immediately ask him what kind of huge and big query he was issuing to EF, but the answer is pretty simple. [...]

Continue reading about Entity Framework error Some part of your SQL statement is nested too deeply

Nhibernate supports lazy loading for single properties and this solves perfectly the situation where a table has on or more field with a lot of data and you absolutely need to avoid loading all that data each time you load the entity. Basically with NH you can define Lazy Properties and the content of that [...]

Continue reading about Entity framework and Table splitting with Code First