The Gold Plating

by Alexandru Lungu 23. August 2010 18:47


I've seen a lot of gold plating lately; and both kinds: programmer and specification. I did programmer gold plating long time ago, but all ended when I became in charge of managing projects and close deadlines made me stop any gold plating attempts. 

But the latest experience with this made me realize who does and who doesn't do it.

People that don't gold plate are the ones that do the job exclusively for the money. They don't want to work more that is minimum necessary, which is a very good thing in trying to meet the deadline.

Gold plating is done by the people that are very passionate about their job; and more often by young people. And I think this is available not only for the software domain. 

Thus I realized that while specification gold plating shouldn't be allowed at all, a little programmer gold plating should be allowed - because otherwise you'll break the enthusiasm and joy of the passionate programmer for which the work itself is a reward.


Project Management


EntitySqlException was unhandled…

by Alexandru Lungu 10. August 2010 07:38


'Name' could not be resolved in the current scope or context. Make sure that all referenced variables are in scope, that required schemas are loaded, and that namespaces are referenced correctly. Near simple identifier, line 6, column 1.

I've got the above error while running the following code (actually the code was a more complex but I reduced it to essentials):

DbTestEntities db = new DbTestEntities();
var query = db.People.Where("Name = 'John'");

(I think it is obvious that I have a test db with a Person table)

There seems to be something wrong with the 'Name' from my expression, but what exactly could it be on such a simple expression? The Name column does exist.

I googled the error and found some people that encountered this error but in different circumstances which didn't get me the solution but put me on the right track: a guy had the same problem with an OrderBy("Column") so it become clear to me that using just the column name isn't going to work.

Next I looked at the sql expression that gets generated and found what was wrong:


Yes, that "it" alias was the problem so the following code works:

DbTestEntities db = new DbTestEntities();
var query = db.People.Where("it.Name = 'John'");

Next the question: can it be always used as it.Column?
After running a few tests the answer is positive.

Can it be changed to other alias name?
Actually it can - looking to ObjectSet's properties I quickly identified the property: Name (dooh! ). 

So now I can do this:

db.People.Name = "People";
var query = db.People.Where("People.Name = 'John'");

And no, it doesn't work to set the Name to empty string (or null). 

I remembered vaguely that long time ago I read a post about using string c# code instead of string sql code.  A quick search on my favorite blogs found this article of Scott Guthrie - Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library) in which he points to an example on how to do that.

IQueryable was extended for this.  I’ve tried and worked as expected:

var query = db.People.AsQueryable().Where("Name == \"John\"");
//or I can use parameters
var query2 = db.People.AsQueryable().Where("Name == @0", "John");

Tags: , ,


Powered by BlogEngine.NET
Original Design by Laptop Geek, Adapted by onesoft