| 8/16/2007 5:04:18 PM |
Hi!
I just found out about some rather curious "feature"... I'm sure it has a simple explanation and I'd like to hear it..
I tried this code just for fun:
ObjectQuery query = new ObjectQuery(typeof(Apple), "Apple.COLOR=6", string.Empty); Manager.GetObjectSet(query);
And it runs and works!! Although the property is actually Color (not COLOR).. Of course it is not checking for this, but I don't know how it populates it!?
This is how it's supposed to be done:
string where = helper.GetExpression("Apple.Color", 6); ObjectQuery query = new ObjectQuery(typeof(Apple), where);
Manager.GetObjectSet(query);
If I change the ".Color" to ".COLOR" in GetExpression it throws QueryHelper: EntityAlias was not Found - Apple.COLOR.. As expected..
So my question is why the first example worked (and correctly binded the property)?
Thank you!
David
|
| 8/17/2007 1:56:47 AM |
Hi David:
The ObjectQuery constructor just wants a raw sql where clause, so if your table is named Apple and your column is named Color, then this works just fine. As for the case being COLOR, most databases are case insensitive when it comes to table and columns (and most everything else for that matter). On the other hand, .net is case sensitive (VB is not, but the IL underneath is), so the mappings and the manner that I store them must be since it matters quite a bit.
So why use the Helper.GetExpression method? Because in many (if not most) cases your objects and members are not named the same as the underlying tables and columns, and you shouldn't have to know that detail since the ORMapper has that information for you.
Thanks, Paul Wilson |