March 2 code update - what's new

Coordinator
Mar 2, 2015 at 6:07 PM
Edited Mar 2, 2015 at 6:09 PM
Hi all
Here is an overview of changes in today's code update:
  1. Search functionality improvements. The old, now deprecated class PredicateBuilder provided convenient methods for building WHERE expressions from a set of optional parameters - a typical task in Search forms. But adding OrderBy clause and Take and Skip - this extra manual code was ugly. Now there's a new SearchParams base class (contains OrderBy, Skip, Take props) and helper method CreateSearch that takes the Where predicate and SearchParams-derived class, and creates the query attaching OrderBy, Take and Skip. OrderBy now is a string that can contain multiple fields, each optionally followed by '-desc' suffix.
    For ex: OrderBy = "BirthDate-desc,LastName,FirstName"
    It can also contain 'short-names' that will be expanded into full paths using mappingDictionary provided as extra parameter to CreateSearch method (ex: pubname->Publisher.Name)
    See BookSearch method for complete sample.
  2. The value returned by ToString() method of entity instances is now based on the 'format' specified by Display attribute. This is equivalent of overriding ToString method in regular classes. Note that ToString() bypasses authorization checks, and can potentially display sensitive info to the user who's not authorized to see it. You should take this into account. The biggest benefactor is traditional WinForms applications - many controls (like Combo) use ToString() representation to show object(s), so it's easy now to customize the appearance. To this reason (that main use will be WinForms apps, on client machine, not shared web server) - the implementation is not very efficient (it is interpreting the formatting expression).
  3. New module EncryptedData - provides encrypted data storage. See more info in about.txt file in module folder
  4. New module OAuthClientData. If your application acts as OAuth client, using external OAuth server(s) like Facebook or Google (to authenticate users for ex), then this module provides the data storage facility for the related information. The use is more less obvious, but I will provide documentation on this site, eventually. The OAuth client itself (connector) is not there yet, but will be, with some examples.
  5. Adjustments with using DbCommand/DbConnection - DbCommand.Connection is set to null after the command is executed; to properly work with SQLite provider (it caches prepared command until DbCommand is disposed, or its connection property is set to null)
Mar 6, 2015 at 5:54 AM
Adjustments with using DbCommand/DbConnection - DbCommand.Connection is set to null after the command is executed; to properly work with SQLite provider (it caches prepared command until DbCommand is disposed, or its connection property is set to null)
This doesn't work yet. ApplyDbModelChanges() in DbModelUpdateManager.cs resets the connection only of the last command that was created in the foreach loop in the try block. The connection resetting should be done for each created command, i.e. inside the loop.

Also, you haven't overridden CommandExecuted() in SQLiteDbDriver, which is also required to release all commands. I suppose you prefer to leave this to clients, which is OK. But if you want to make out-of-the-box Vita unlock the SQLite database file, that override will be needed. You can verify that the file is being unlocked with this simple test:
    [TestMethod]
    public void TestSqliteStatementFinalization()
    {
      var session = _app.OpenSession();
      session.NewDriver( "D137", "John", "Dow" );
      session.SaveChanges();
      Assert.IsTrue( System.IO.File.Exists( @"VitaTestSQLite.db" ) );
      System.IO.File.Delete(@"VitaTestSQLite.db");
    }
Regards,
Ivan
Coordinator
Mar 6, 2015 at 6:42 AM
thanks, will look into this. Yes, I decided not to override OnCommandExecuted just to try to reset connection for all drivers - it wouldn't hurt others I thought. Apparently I overlooked something and was too much in a rush to run specific tests for all cases.
I will address this in the next push. Thank you very much!
Roman
Coordinator
Mar 12, 2015 at 7:56 AM
Ivan,
I'm having some trouble reproducing this SQLite effect, and see some strange behavior. I'll start a separate thread to discuss this problem.