Online Data Access Layer Code Engine
Blocks

The benefits

CodeEngine.Framework v1.2 Changelog

Listed below are all changes that have recently been made to the CodeEngine Framework version 1.2.

Please note that version 1.2 will only be updated with bugfixes, new features will not be added anymore. Switch to the 1.3 framework and a newer templates version as soon as possible.

Version 1.2.2338.28189 (DLL date 2006/05/27)

Type Source Description
Feature WhereStatement class Added support for NOT IN and NOT BETWEEN where clauses. The IN and BETWEEN clauses were already supported, their NOT versions had been forgotten at first implementation.
Feature WhereStatement class Added a check to prevent 1) an empty array being passed to the the AddWhere method, when the comparison operator is IN or NOT IN; and 2) an array with other than 2 dimensions being passed to the AddWhere method, when the comparison operator is BETWEEN or NOT BETWEEN. If the added clause fails any of these conditions, and exception will be thrown.

Version 1.2.2332.30384 (DLL date 2006/05/21)

Type Source Description
Feature WhereStatement class The WhereStatement now allows clauses to be added to level 0 of a query, which makes it possible to add a clause which will be AND'ed to all the clauses on other levels (which are all OR'ed together). This allows you to create more powerful and flexible queries, easier. The default level is still 1, so existing code will still work.

Basically, this feature is something I've always missed in the querybuilder of SQL Server Enterprise Manager. It's simply the 1 column which would define the criteria that must be met for all criteria mentioned in the other columns. And this means: No more adding those recurring criteria to every single 'Or..' column!

Let me give you an example. Previously, if you wanted to create a query that would check if records in the Orders table had CustomerID=123 and had placed their order before '2000/01/01' or after '2006/01/01', you would have to write the following code:
query.AddWhere( Customer.TableColumns.CustomerID, 
Comparison.Equals,
123); // Add to default level 1



query.AddWhere( Customer.TableColumns.OrderDate,
Comparison.LessThan,
new DateTime(2000,1,1)); // Add to default level 1
query.AddWhere( Customer.TableColumns.CustomerID,
Comparison.Equals,
123,
2); // Manually add to level 2
query.AddWhere( Customer.TableColumns.OrderDate,
Comparison.GreaterThan,
new DateTime(2006,1,1),
2); // Manually add to level 2

Calling query.BuildQuery() would result in this query: .. WHERE (CustomerID=123 AND OrderDate<'2000/01/01') OR (CustomerID=123 AND OrderDate>'2006/01/01') Now, you can simply add the CustomerID check to level 0 as follows:
query.AddWhere(	Customer.TableColumns.CustomerID, 
Comparison.Equals,
123,
0); // Add to level 0 query.AddWhere( Customer.TableColumns.OrderDate,
Comparison.LessThan,
new DateTime(2000,1,1)); // Add to default level 1
query.AddWhere( Customer.TableColumns.OrderDate,
Comparison.GreaterThan,
new DateTime(2006,1,1)); // Add to default level 1

Calling query.BuildQuery() would now result in this query: .. WHERE (CustomerID=123) AND (OrderDate<'2000/01/01' OR OrderDate>'2006/01/01'). As you can see, a real improvement for easy query building! See my article on the QueryBuilder at CodeProject (http://www.codeproject.com/cs/database/SelectQueryBuilder.asp) for more information about using levels. Please note that at the time the CodeProject article was written, this feature wasn't implemented yet.
Bug WhereStatement class

Description: The static method CombineWhereStatements wasn't working properly in all cases.
Resolution: The method has been completely rewritten, it now also supports the new 'level 0' feature.

Change CollectionBase class

Description: Adjusted the GetSqlCount and private GetSqlCountQuery methods to use the new 'level 0' feature and improved CombineWhereStatements method.

Version 1.2.2331.25280 (DLL date 2006/05/20)

Type Source Description
Feature SingularBase class Description: GetUpdateCommand and GetDeleteCommand check if the table has a primary key defined on it. If not, it will raise an exception. This prevents an Update or Delete call on a single record from updating or deleting all records in that table.
Bug WhereStatement class Description: BETWEEN clauses in the WhereStement class weren't handled properly when calling the BuildCommand method.

Resolution: Problem has been solved.
Bug SingularBase class Description: Setting the PK property on a populated class would attempt to update the PK value in the database. This results in an error if the PK field is an Identity column.

Resolution: The PK field value will not be updated when calling Update().
Bug SingularBase class Description: When binding a collection (exposed through a relationship) to a DataGridView, adding new records through the datagrid resulted in an error. This was caused by the AutoPopulate method.

Resolution: Added a 'Parent object' check to the AutoPopulate method, if the parent is a collection, Autopopulating is cancelled.
Feature SingularBase, CollectionBase Description: Adding an unpopulated record to a collection exposed through a relationship will automatically set the FK field value to the PK value of the parent object. The SingularBase.InitializeRelationalData method will be called from the CollectionBase.OnInsert event handler
Customer customer = Customer.FindByCustomerID(123);
Order order = new Order();
customer.Orders.Add(order);
MessageBox.Show(order.CustomerID); // Displays '123'

Version 1.2.2324.27182 (DLL date 2006/05/13)

Type Source Description
Change SingularBase Description: Moved the RecordSafetyEnabled property from SingularBase to the ObjectProperties class. Instead of calling customer.RecordSafetyEnabled = false, now use customer.ObjectProperties.RecordSafetyEnabled = false instead.
Bug WhereStatement class Description: IN clauses in the WhereStement class weren't handled properly when calling the BuildCommand method.
Resolution: Problem has been solved.
Change WhereStatement class Description: FormatSQLValue method put single quotes (') around values when they were of an unhandled type. This caused those quotes also being put around values of types like int and long when calling BuildQuery method.

Resolution: Quotes will not be put around unhandled types anymore, the output of the type's ToString() method will be used. If this causes problems for you, cast your variable to a handled type when adding it to a Where statement. Handled types are: String, DateTime, DBNull, Boolean, Guid, SqlLiteral and SelectQueryBuilder.
Bug CollectionBase class Description: OnListChanged event wasn't fired when the collection changed. This caused a DataGridView displaying the data not being refreshed.
Resolution: Problem has been solved.
Feature CollectionBase class Description: Added RecordSafetyEnabled property to the CollectionBase class. When updating a record in the database, the Update method will assert that the amount of affected records is equal to the expected amount. If not, it will raise an error. If you have defined any triggers on a table that don't use SET NOUCOUNT ON, this could cause an error. By setting RecordSafetyEnabled to false, this check will not be done. The default is set to true.
Bug CollectionBase class Description: When adding a record to an empty collection, the Populated property wasn't set to true, which caused an Update call on the collection not to save the new record.
Resolution: Problem has been solved.
Bug CollectionBase class Description: When adding a record to a collection through a DataGrid, the DataChanged property wasn't set to true.
Resolution: Fixed.
Bug CollectionBase class Description: After calling the Update method, the DataChanged property wasn't reset to false.
Resolution: Fixed.
Security Framework DLL Description: Strong signed the CodeEngine.Framework.dll.
Bug WhereStatement class

Description: When adding a NULL value to a where statement, the BuildCommand method passed this NULL value in a parameter. This caused SQL server to return no records at all.

Resolution: BuildCommand will now add 'field IS NULL' or 'NOT field IS NULL' to the query text, instead of 'field = @p1_fieldname' with parameter @p1_fieldname containing a null value.