Wednesday, March 26, 2014

Entity Framework ... you've failed me

I used to like EF, since the day I started to understand the power of a well designed ORM Framework. It was performing well in 4.1, maybe even 5.x, but 6.x is frankly ... a disaster.

I started working on a simple WPF app, with MVVMLight Toolkit, and to experiment with various data binding approaches I have decided to give EF 6.1 a shot. Instead, it felt like shooting myself in the foot. Don't get me wrong, I still like the designers and the myriad of possibilities how an ObjectSet can be mapped to a set of tables and views, but I'do expect a decent performance all along. Obviously, it will not be faster than ADO.Net or DAO (yuk!), but it should be close. When my form was loading, I simply asked the provider, on a background thread, to get me the total count of all objects from one set. The query was properly prepared and executed, with just the right amount of SQL needed, but execution times were horrible: over 8 seconds for Code First approach, and over 5 seconds using EF Designer. I've only pulled a subset of tables from the database, to reduce the size of the data layer, so to wait that long for a simple count query to return was quite a shocker. Especially when the same query executed in milliseconds in SSMS and 325ms with micro-ORM Dapper. In addition to that, the Code First approach generated a bunch of SQL statements which failed due to some tables not being present in destination (I did not capture their names, but they looked to me to be code-first-designer related).

Perhaps I am doing something wrong, perhaps using an incorrect approach. Until you or I mature, my dear EF, we should see other people.

Wednesday, November 20, 2013

Bringing back the Programs start-menu in Windows 8

For months now, in Windows 8, I missed my old trusty Programs folder, where my Start button used to be. And today, thanks to Toolbars feature, I have it back. Simply:

  1. Right click on the Toolbar
  2. Select Toolbars - New toolbar ...
  3. Than paste "C:\ProgramData\Microsoft\Windows\Start Menu\Programs" into the Folder location
Enjoy!

Tuesday, June 4, 2013

Parameterized SQL and IN clause

There are many ways to pass table value parameters to an SQL statement in C#. I did not like any of them, since they were either:

  • Not secure - by concatenating table values, which exposes your application to SQL injection attacks
  • Not performing - by utilizing SQL Server pattern matching, i.e. LIKE '%...%'
  • Cumbersome - by requiring special type to be created on the database server
  • Quite weird - by creating CSV split function and joining the result to the original query
So I have decided to create my own and share it with the world on the CodeProject site.

http://www.codeproject.com/Tips/602581/Passing-NULL-and-table-values-to-parametrized-SQL