orsted wrote:So I see what EasyObjects is doing - my question is, why isn't the default behaviour "overridden" when I do include the
emp.Query.AddConjunction(NCI.EasyObjects.WhereParameter.Conj.And) statement ?
The dynamic queries are designed to be as flexible as possible. While your point is well taken, it is still possible for the developer to construct queries which contain errors or return incorrect results.
(As a side point, I'm not real thrilled with Oracle's "helpful" error messages either.)
The automatic injection of the AND conjunction is meant to be a shortcut for developers, so they don't have to specify it every time (you can also override it by calling Query.Load("OR")). The AddConjunction call is really there for constructing complex queries that use a combination of AND and OR (see Mike's excellent post on querying with dOOdads
There is no "on the fly" query parsing, either. EO basically relies on the db engine to process the query and either throw an error or return the results (why reinvent the wheel?). That's why the LastQuery property is there, so the developer can check how the query was constructed and correct any mistakes.
I will take a look at making the enhancement you suggest, but as I'm close to releasing version 1.0, I don't think this will make it.
orsted wrote:In addition - is there a way to use EasyObjects to return queries based on results from multiple joined tables? The reason I ask is that this "simple" query is just from one table, but the eventual need will be to return data from 5 different tables joined together?
You have a few of options open to you.
- You can create a View, join the tables in the View and set the QuerySource property on the EO to the View. The EO can contain any results, even if they bear no relationship to the table the EO was generated from. You can also create an EO based on the View using the Business Entity View template.
- You can join the tables in a proc and use the LoadFromSql functions to load the EO with the results.
- You can write some inline SQL and use the LoadFromSql functions to load the EO with the results.
- You can call the EntLib DAAB directly and return a DataSet.
Let me know if you have any other questions. I'm curious about your experiences with Oracle.