Sunday, April 27, 2008
kick it on DotNetKicks.com

imageThe EntitySpaces 2008 Beta II is now available. The version number is 2008.0.0427.0 and is available for download now on our home page. You should uninstall any prior ES2008 alpha or beta that you may have installed. You can run ES2007 and ES2008 side-by-side. Do not install ES2008 over the top of ES2007. EntitySpaces 2008 has proven to be a big undertaking. Every EntitySpaces template has been rewritten using our new metadata engine and is now supported in both MyGeneration and CodeSmith, many were converted from VBScript to C#. However, from this point forward we start knocking off issues on our roadmap in rapid fire fashion. We are a little behind on our May 15th release date, but not too far. Not only is the trial available for download but both the Developer version and Source version are available to customers as well.

The testing behind this release is tremendous. We have two code generators in play, C# and VB.NET templates, and to top it off we had to debug Oracle subquery issues with messages like "ORA-923 No worky, try again" (kidding, but only slightly). Throw in database independence, the Compact Framework, and you really have your hands full. However, we are over the hump now and can see the light. This is a little off topic but we cannot wait to put up our Silverlight demo showing EntitySpaces working hand-in-hand with Silverlight. Our Silverlight demo is being worked on by Jon Davis and when we saw his first cut we were very impressed, Jon is a very sharp guy indeed.

We've made some good changes too with our installs. Both our Trial and Developer versions install exactly in the same folder structures. This will avoid confusion for those folks who use the EntitySpaces Trial for a large part of their development process and then purchase the Developer version before going live. Now you can simply install the developer version right over the top of the trial and not worry about changing reference paths. This beta comes with all providers, including our Compact Framework providers, it also comes with a SQL CE desktop provider in addition to the Compact Framework version. The beta will automatically install into both MyGeneration 1.2 and 1.3 folders and add support for CodeSmith. See the Getting Started documents on your menu after installation. There is a "Getting Started.PDF" for both MyGeneration and CodeSmith. Just a quick note for our MyGeneration customers. If you have any user meta data defined for aliases or Oracle or PostgreSQL sequences be sure to run the UserData template. It will convert the MyGeneration user data file to our new format upon first run. From that point on you maintain your user meta data via our UserData template and not through MyGeneration.

image

You can see by the image on the right that the runtimes are easily found in the Runtimes folder. We have both .NET 2.0 and 3.5 assemblies as well as Compact Framework assemblies (we now use CF and not Ce for those in our naming convention). Also notice that the CodeSmith templates are under the EntitySpaces 2008 folder. The "Getting Started.PDF" for CodeSmith will show you how to setup a Template Folder Shortcut in CodeSmith, it's a snap.

Our ES2007 EntitySpaces demo still hasn't been converted thus our ES2008 demo is very lightweight. We are going to rewrite it and not just convert it so that's the reason why we've held off. There could be some minor breaking changes coming when we tackle a few things on the roadmap, however that's not the usual case for EntitySpaces. We do want to address a few things to make your lives easier though.

We really hope a lot of our users start taking a serious look at ES2008, our Subquery and Casting support is very powerful and we will have a ton of enhancements rolling out soon as we head for the official release. We have also prototyped LINQ to SQL with EntitySpaces. And even more exciting when talking to Jon Davis about Silverlight we spoke about adding the very popular EntitySpaces DynamicQuery API to our proxies as an option. You could then issue full ES2008 dynamic queries from within Silverlight (down in the client) and from other situations such as WCF conversations where you might not have EntitySpaces on the client. All of this is to say that when we release EntitySpaces 2008 that is not the end, but the beginning.

We are very excited about where we are going and have a great vision for EntitySpaces. Not only can we run on Mono, Medium Trust, the Compact Framework, but we can provide seamless support for Silverlight as well. Mike Griffin will be demonstrating a lot of these high end features at the Indy ALT.NET meeting on May 15th.

So download the ES2008 Trial and if you hit a snag please post on the forums and we'll get you a speedy response.


EntitySpaces

From mobile devices to large scale enterprise solutions in need of serious transaction support, EntitySpaces can meet your needs. Whether you’re writing an ASP.NET application with medium trust requirements, a Mono application, or a Windows.Forms application, the EntitySpaces architecture is there for you. EntitySpaces is provider independent, which means that you can run the same binary code against any of the supported databases. EntitySpaces is available in both C# and VB.NET. EntitySpaces uses no reflection, no XML files, and sports a tiny foot print of less than 200k. Pound for pound, EntitySpaces is one tough, dependable .NET architecture.

The EntitySpaces Team
--

EntitySpaces LLC
Persistence Layer and Business Objects for Microsoft .NET
http://www.entityspaces.net

posted on Sunday, April 27, 2008 9:22:04 PM (Eastern Standard Time, UTC-05:00)  #   
 Sunday, May 20, 2007

Or how to write a complete master detail view in 2 lines of code!

In my previous article I showed how it was possible to write a complete Windows Mobile 5 application in a ridiculously small amount of code. Using the full power of the Resco controls and the simplicity of the EntitySpaces architecture this can be simplified even more.

AdvancedList

The top half of our form uses the Resco AdvancedList control. This shows a complete list of all the rows in the Surveys collection. An un-selected row displays the contents of the column 'Name', a selected row expands to display two lines and now includes the column 'Address' in the second row.

Screen Shot of the Resco AdvancedList Designer in action

The definition of this behavior is carried out at design time. Within the code all we have done is instantiated the 'Surveys' EntitySpaces collection  and attached it to the AdvancedList using the collection as the datasource for the control.

this.advancedList1.DataSource = surveys;

The cell 'Address' we have created in the 'Selected' template has its CellSource set to Address, normally this property combination in the properties dialogue is collapsed and the ColumnName and SourceType are set correctly to their appropriate values by default.

DetailView

Recalling my previous article we used the Resco DetailView control to display the full details of the record. Most of the work required to achieve this was done in 3 lines of code.

((Resco.Controls.DetailView.ItemComboBox)this.detailView1.Items["HType"]).DataSource = types;
((Resco.Controls.DetailView.ItemComboBox)this.detailView1.Items["HType"]).DisplayMember 
= HTypesMetadata.PropertyNames.Htype;
((Resco.Controls.DetailView.ItemComboBox)this.detailView1.Items["HType"]).ValueMember 
= HTypesMetadata.PropertyNames.Id;

It is in fact possible to use the design time capability of the Resco control to eliminate all but the line which does the primary datasource binding, thus reducing this to just 1 line of code!

In the screen-shot above you can see the combobox properties being set using the DetailView designer.

In conclusion we have demonstrated some of the power of EntitySpaces when used in conjunction with sophisticated but easy to use Resco Controls. This approach can obviously be extended to any third party controls that properly support data binding in this way. Remember we have built a fully functional Master-Detail application without ever writing any SQL code at all !


Robert Campbell ecommnet Robert Campbell
ecommnet ltd., Bewick House, Horsley Business Centre, Horsley, Newcastle Upon Tyne, NE15 0NY UK
www.ecommnet.co.uk  www.offexploring.com  www.autobestbuy.co.uk


posted on Sunday, May 20, 2007 4:23:34 AM (Eastern Standard Time, UTC-05:00)  #   
 Tuesday, May 15, 2007

This is our first user supplied EntitySpaces blog post. We hope to do more of these in the future as we have some customers doing some pretty cool stuff with the EntitySpaces architecture. A special thank you goes out to Robert Campbell of ecomment ltd. See Robert's bio at the end of this post. - The EntitySpaces Team.


In this article we’ll develop an application for a Windows Mobile ("WM5") platform device. While the application is just an example, and some would argue an incomplete one at that, we will be able to see all the necessary steps to get started with EntitySpaces (“ES”). We’ll also see how to use data source binding on a couple of 3rd party controls. You can also see a FLASH DEMO as well.

Getting Started

Prerequisites: What you need

    • Microsoft SQL Server Compact Edition
    • Microsoft SQL Server 2005
    • MyGeneration Version 1.2.0.6
    • EntitySpaces 2007 Beta v0.0507
    • Visual Studio 2005 with Windows Mobile 5 SDK installed
    • Resco AdvancedList.NET. See http://www.resco.net/products/

Create a new VS Project for Windows Mobile 5

In Visual Studio (“VS”), Clicking ‘File’ > ‘New’ should produce the New Project dialog below . I’ve selected ‘Windows Mobile 5.0 Pocket PC’, ‘Device Application’, and changed the Name to ‘Demo’.

Clicking OK at this point should result in a new project called Demo with a single blank form.

The interesting things to notice here are the default references VS implements because we’ve targeted the WM5 platform.

Create a Database

Creating a database file for use in our application is relatively simple if MS SQL Server has been installed properly.

In VS, Click the project icon in the solution tree (shown above as ‘Demo’), Right-Click, and Click ’Add’ > ’New Item...’. Select ‘Database File’ in the Add New Item dialog.

I changed the Name of the database file to Demo.sdf.

Click ‘Add’, and the standard VS Data Source Configuration Wizard pops up.

We’ll not need this as we’re going to use ES!!

Click ‘Cancel’ instead.

Double-Click the database file that appeared in the Project Solution Explorer tree.

The Server Explorer pane should now appear in your VS IDE.

If the connection to the database is closed (indicated by the little red ’x’ next to the Demo.sdf database icon), Right–Click and Clicking ’Refresh’ should restore it.

We can now build the database proper.

Right-Click on the Tables icon. Click ‘Create Table’. This will present a familiar New Table Dialog.

In this screenshot I’ve created a table called Survey and added the 5 columns.

Note the Id column is a Unique Identifier, is set as the Primary Key, is a ‘RowGuid’, and it’s practical to set the default value for the column as (newid()).

Create a second table which will be used as a related table. In this demo we’re going to use a table called HTypes (house types) for our survey.

We need to relate the two tables with some foreign key constraints. In SQL server ‘proper’ this is easily done with the relationship diagram tool in VS. However, with SQL CE or ‘Compact Edition’ as it’s now called, that’s not possible. We’ll have to do this programmatically with a TransactSQL Query.

SQL Reference (SQL Server Compact Edition) 

http://msdn2.microsoft.com/en-us/library/ms173372.aspx

I usually have to resort to the Microsoft SQL Server Management Studio to run this query as the VS component doesn’t support the ‘ALTER’ command (Anyone have any idea why? Or, indeed, why the Management Studio doesn’t support the ability to ‘Open’ tables?)

To add a constraint to the Survey table, we need to run this query:

ALTER TABLE [Survey] ADD CONSTRAINT [FK_Survey_HTypes] FOREIGN KEY([HouseType]) REFERENCES [HTypes] ([Id])

Note, in this simplified demo, I have just taken the defaults for the behavior for this constraint. A lot of this will depend on your real application. I’m no DB expert, and this is an ES demo.

At this point we have:

  • A WM5 VS project shell.
  • An SQL-CE database with tables and FK Table Constraints.

Let’s add two folders to our VS project for the files generated in the next section. Click the Project icon in the solution tree. Right-Click and Click ’Add New Folder’. Add a folder called ‘Generated’ and another called ‘Custom’.

Note the highlighted Project Folder property. You’ll need this information in the next section. The next step is to produce the ES generated classes.

MyGeneration

Start MyGeneration, and select ‘Edit’ > ‘Default Settings...’.

Click ‘Microsoft SQL CE’ from the ‘Driver’ dropdown. The easiest place to get the Connection String is by copying it from the properties dialogue of the Demo.sdf file in VS, and pasting it in the text box here. Click ‘SqlServerCe’ in the ‘DbTarget’ dropdown. Optionally, click your preferred language in the ‘Language’ dropdown, in this case, ‘C#’.

Click ‘Test Connection’ to confirm a valid connection can be established.

Click the Templates Tab of the dialogue.

All we really need to change here is the Default Output Path.

Copy the Project Directory path that was noted in the previous screenshot, and paste it to the Default Output Path here. The template will automatically find the Generated and Custom directories.

Click OK. This should start the connection to your database.

You should now be able to select and expand the MyMeta tree to show the database we have created in all its glory.

Go Generate!

Select the Template browser from the icons at the top of the left hand side of the MyGeneration IDE. Expand the EntitySpaces folder and the C# folder below that.

We’re going to run two templates:

  • Custom Classes Master (C#)
  • Generated Classes Master (C#)

We’ll Double-Click a template to load it, and click the green ‘go’ arrow to generate. Let’s start with the Custom Classes.

Custom Classes Template

Note the template has automatically selected the \Custom\ folder.

The Namespace defaults to ‘BusinessObjects’. Change this to ‘Demo’.

Ctrl-Click both tables to select them in the Select Tables window. Click the OK button/bar.

If everything goes according to plan, the output will be shown in the output tab / window.

Generated Classes Template

Double-Click on the Generated Classes Master template and Click the green ‘go’ button again.

This dialogue has two tabbed sections.

For the Basic Information tab, make the same edits as for the Custom Classes template. Again, the Output Path should be automatically filled in for you.

Click the Advanced Options tab.

On this tab we need to check the options as shown:

Important: The Ignore Schema, Ignore Catalog, and Target Compact Framework boxes need to be checked.

Click OK.

Again, if it’s worked, the output should show in the pane on the right.

We’re done with MyGeneration, either close or minimize the application.

Incorporating the generated code into the VS project

Go back to VS, and Click the ‘Refresh’ icon. Click the ‘Show All Files’ icon.

We now can see our generated files in both directories but grey’d out. As yet, they’re not part of the project.

Highlight them all using the usual Shift-Click and/or Ctrl-Click techniques. Right-click one of the highlighted files, and Click ‘Include In Project’.

Hey! Just before you go clicking ‘Build’, we need to do one more thing. Add the ES references to the project.

To do so, Click the References node in the solution tree, Right-Click and Click ‘Add Reference...’.

At this point, the current documentation suggests that the ES DLLs will be there ready to select. In my case, they were not, so Click the Browse tab and drill down to the CE directory in the place where EntitySpaces is installed. The default, and in my case, is:

C:\Program Files\EntitySpaces\Redistributables\CE

The Add Reference dialogue should look like this:

We need to Ctrl-Click Core.Ce, Interfaces.Ce, LoaderMT.Ce, and SqlClientProvider.Ce. Then, Click OK.

Your Solution tree should now look like this:

Quick! Click ‘Build’ before you collapse in anticipation!

‘Build Succeeded’

“Ah”, you cry, “It looks great, but doesn’t do anything!”

Wait… there’s more....


Adding some code!

Program.cs

The application needs to have added the medium trust loader, and, because we need a configless implementation in WindowsCE, Program.cs needs to look something like this.

using System;
using System.Collections.Generic;
using System.Windows.Forms;
using EntitySpaces.Interfaces;
using EntitySpaces.LoaderMT;

namespace Demo
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [MTAThread]
        static void Main()
        {
            // --- Manually register a connection (DO THIS ONE TIME ONLY) ---
            esConnectionElement conn = new esConnectionElement();
            conn.ConnectionString = @"Data Source=\program files\Demo\Demo.sdf;";
            conn.Name = "Demo";
            conn.Provider = "EntitySpaces.SqlClientProvider.Ce";
            conn.ProviderClass = "DataProvider";
            conn.SqlAccessType = esSqlAccessType.DynamicSQL;
            conn.ProviderMetadataKey = "esDefault";
            conn.DatabaseVersion = "2005";

            // --- Assign the Default Connection ---

            esConfigSettings.ConnectionInfo.Connections.Add(conn);
            esConfigSettings.ConnectionInfo.Default = "Demo";

            // --- Register the Loader ---

            esProviderFactory.Factory = 
new EntitySpaces.LoaderMT.esDataProviderFactory(); Application.Run(new Form1()); } } }

Form1.cs

Our ‘spec’ calls for a form that displays a grid with all the survey results, so we should add a grid. We’re going to use a 3rd party specialist grid, the Resco AdvancedList, and a panel to display the record with all its detail. Here, I’ve used the Resco DetailView.

Initializing our form

Of the many things to do to the form, the first is to add the two ES collections by dragging the icons from the toolbox to the form. Using this method, all the necessary defaults are created and end up in the designer.cs file.

I’ve also done a similar thing with the two Resco controls; the advanced list and the detail view.

I've created a method to initialize the form:

private void init()
{
    // The Grid is populated with the collection of surveys
    // just get everything; 
    if (surveys.LoadAll())
    {
        this.advancedList1.DataSource = surveys;
        this.advancedList1.Refresh();
    }
   else 
   {
        MessageBox.Show("can't load survey data");
   }
}

The record detail is displayed in a control called DetailView, We need to populate the combobox on the related field, load the collection, and bind it to the ComboBox

 

private void init()
{
    // The Grid is populated with the collection of surveys
    // just get everything;                           
    if (surveys.LoadAll())
    {
        this.advancedList1.DataSource = surveys;
        this.advancedList1.Refresh();
    }
    else 
    {
       MessageBox.Show("can't load survey data");
    }

    if (types.LoadAll())
    {
        //This sets the DataSource of the ComboBox to the collection
        ((Resco.Controls.DetailView.ItemComboBox)this.detailView1.Items["HType"]).DataSource 
= types;
((Resco.Controls.DetailView.ItemComboBox)this.detailView1.Items["HType"]).DisplayMember
= HTypesMetadata.PropertyNames.Htype;
((Resco.Controls.DetailView.ItemComboBox)this.detailView1.Items["HType"]).ValueMember
= HTypesMetadata.PropertyNames.Id; this.detailView1.Refresh(); } }

By the time we exit this method, we've done everything to populate the grid, and related fields, in the record detail display... in 12 lines of code... and NO SQL or recordset/dataset stuff to remember.


Display the Record Detail

Using the AdvancedList ("AL") to allow a user to select a record to display, we have a method showDetails. This method uses the Id of the record as its parameter. This is usually called by a row select event handler on the AL.

private void showDetails(Guid rowToEdit)
{
    s = new Survey();
    s.LoadByPrimaryKey(rowToEdit);
    this.detailView1.DataSource = null;
    this.detailView1.DataSource = s;

    this.detailView1.Refresh();
}

The method simply creates a new Survey entity, and loads it with the record data using the ES LoadByPrimaryKey() method. This binds the resulting object to the DetailView control through the assignment of the DataSource.

The ES entity ‘s’ is visible across the form.

If the user selects another row in the grid, we need to detect if they have made any changes to the current record, and save it.

private void askSave()
{
    if (s.es.IsDirty)
    {
        DialogResult result = MessageBox.Show("Save changes?", "ES Test App", 
MessageBoxButtons.YesNo, MessageBoxIcon.Question,
MessageBoxDefaultButton.Button1); if (result == DialogResult.Yes) { s.Save(); this.surveys.LoadAll(); this.advancedList1.DataSource = this.surveys; this.advancedList1.Refresh(); } } }

The 1st thing the askSave method does is to determine if the data has been altered using the property of the underlying entity. if (s.es.IsDirty)

Having determined it is, and that the user indeed wants to save it, it’s a simple matter to call the Save() method on the entity itself. After which, a call to reload the surveys collection and a refresh of the AdvancedList grid is all that’s required.


Adding a new record

Adding a new record is easy, too. I have an event attached to an AddNew menu item that looks like this.

private void AddNew_Click(object sender, EventArgs e)
{
    Survey s = new Survey();
    s.AddNew();
    showDetails((Guid)s.Id);
}

The ES AddNew() method is called to create a new entity and the Guid is passed to showDetails() to display it for editing.

Note: The AddNew() method is overloaded in the Custom Class to generate the Guid immediately rather than relying on the default mechanism in the database.

public partial class Survey : esSurvey
{
    public override void AddNew()
    {
        base.AddNew();
        this.Id = Guid.NewGuid();
    }
}

Conclusion

And... there you have it; a VS WM5 solution, an SQL Ce database, some easily generated ES BusinessObjects, a couple of Resco controls, and a few lines of code, all blended into a working application. After you've done it once, you can probably do your next project in less time than it took you to read this. Enjoy! 


 

Robert CampbellRobert Campbell was educated in Newcastle Upon Tyne University in Agricultural Engineering, worked in manufacturing for 15 years before moving into IT in the mid 80's, and worked for a variety of consulting organizations before setting up ecommnet in 1998 at the start of the dot.com boom to specialize in security and web based applications development. ecommnet is now specializing in mobile applications development and security, Web 2.0 and identity management. ecommnet are NOKIA Enterprise Solutions Certified Mobility Partners.

ecommnet ltd., Bewick House, Horsley Business Centre, Horsley, Newcastle Upon Tyne, NE15 0NY
DDI: +44 8451-740-633, T:+44 1661 854 492 F :+44 1661 854 632 M:+44 7801 270 264

posted on Tuesday, May 15, 2007 5:17:08 PM (Eastern Standard Time, UTC-05:00)  #   
 Saturday, December 02, 2006
The EntitySpaces team decided to take a slight detour from its upcoming 1.6.0 release and add support for the Compact Framework to its popular architecture, which is a persistence layer and business object system for Microsoft .NET 2.0. Support for the Compact Framework paves the way for VistaDB 3.0 and the Microsoft SQL Compact Edition well in advance of their official releases. Both VistaDB 3.0 and the Microsoft SQL Compact Edition are still in CTP mode. EntitySpaces classes are generated from your database schema using download.com's #1 download in the .NET development category, MyGeneration, using the EntitySpaces template suite.

EntitySpaces LLC has created a sample application using a very powerful combination of its EntitySpaces architecture in conjunction with VistaDB 3.0, and running both under the Windows Mobile 5.0 Smartphone emulator. Setting up the demo solution was very simple. First, references to the EntitySpaces.Core.Ce and EntitySpaces.Interfaces.Ce assemblies were added. Next, a reference to the EntitySpaces.VistaDB.Ce data provider was added. Finally, the VistaDB Northwind.vdb3 database was added to the project and its "Build Action" was set to "Content" to ensure that the database is copied along with the other assemblies to the proper folder when the simulator is launched. To see the solution in Visual Studio click HERE.


Click here for a larger view The next step was to write the code to connect to the VistaDB Northwind database. To accomplish this, the new configless execution feature provided by the recent EntitySpaces 1.5.2 release was used. The trick was actually figuring out how to get the correct path to the database while running in the simulator. You can see how this was accomplished in the first line of the following code snippet.

    string cnString = ("Data Source =" + (System.IO.Path.GetDirectoryName
     (System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase) +
     "\\Northwind.vdb3; Open Mode = ExclusiveReadWrite"));

    // What the heck let's register a connection
    esConnectionElement conn = new esConnectionElement();
    conn.ConnectionString = cnString;
    conn.Name = "VistaDb";
    conn.Provider = "EntitySpaces.VistaDBProvider.Ce";
    conn.ProviderClass = "DataProvider";
    conn.SqlAccessType = esSqlAccessType.DynamicSQL;
    conn.ProviderMetadataKey = "esDefault";
    esConfigSettings.ConnectionInfo.Connections.Add(conn);

    // Assign the Default Connection
    esConfigSettings.ConnectionInfo.Default = "VistaDb";


The only option on the opening Menu brings the user to a form which contains a DataGrid bound directly to an EntitySpaces EmployeesCollection object loaded with all of the employees in the database. Note that you can use the EntitySpaces collections in design time mode directly on the form itself, this can be seen HERE. The EntitySpaces dynamic query mechanism was used to limit the columns brought back from the database to only those needed to operate the DataGrid. These included the EmployeeID, FirstName, and LastName columns. Finally, the DataGrid TableStyles collection was used to set the EmployeeID column's width to zero so that it would not be visible. The only thing left to do is fetch the data and assign the EntitySpaces collection directly to the DataGrid.DataSource property.

The developer will never need to use any ADO.NET code, or any specific VistaDB code to accomplish this task. In fact, the developer could easily swap out the EntitySpaces VistaDB provider and exchange it for the EntitySpaces Microsoft SQL CE provider, and run the same exact binary code. The EntitySpaces architecture itself is tested using NUnit against all five supported databases using the same exact binary code. No recompilation necessary. The code used to fetch the data and bind to the DataGrid is shown below and taken from the FormGrid class in the demo.

 

Click here for a larger view     private void PopulateGrid()
    {
        EmployeesCollection empColl = new EmployeesCollection();
        empColl.Query.Select
            (
                empColl.Query.EmployeeID,
                empColl.Query.FirstName,
                empColl.Query.LastName
            );
        empColl.Query.Load();

        this.theGrid.DataSource = empColl;
    }

It really is that simple. Next, the "Edit Record" menu item needs to be handled in order to navigate to the editing form. To accomplish this the hidden EmployeeID needs to be grabbed, and passed to the "FormEdit" page based on the selected row at the time the "Edit Record" menu item is clicked.

    private void menuItem_EditRecord_Click(object sender, EventArgs e)
    {
        int index = this.theGrid.CurrentRowIndex;
        int id = (int)this.theGrid[index, 0];  // index is the row
                                               // zero = the first column
        FormEdit form = new FormEdit(id);
        form.Show();
    }

It is on the editing page where users can modify, delete, and add new records. Remember from above that the EmployeeID is passed to the FormEdit page. The constructor for the FormEdit page is very easy to implement using EntitySpaces architecture. Here, instead of the EmployeesCollection, the Employees class is used to load the correct record. The Employees class is used to hold a single record, whereas, the EmployeesCollection holds a set of Employees classes. The record is loaded using the LoadByPimaryKey method as shown in the code snippet below. Finally, the labels and textbox controls are populated with the data from the EntitySpaces Employees object. 


 

Click here for a larger view

 

 

    public FormEdit(int employeeID)
    {
        InitializeComponent();

        Employees emp = new Employees();
        if (emp.LoadByPrimaryKey(employeeID))
        {
            this.lblID.Text = emp.str.EmployeeID;

            this.txtFirstName.Text = emp.FirstName;
            this.txtLastName.Text  = emp.LastName;
        }
        else
        {
            this.lblError.Text = "Employee not found";
        }
    }

On the editing screen shown on the left Margaret's first name has been changed to "Mary" and then saved using Save on the menu. The ability to add and delete records is in the EntitySpaces Mobile demo too but not shown here. Pressing close will return the user to the DataGrid form reflecting any edits that may have occurred. The image on the right reveals that not only was Margaret's name changed to Mary, but "Mike Griffin" was added to the database as well. The grid is refreshed in the Activated event of the FormGrid class. 

It should be clearly seen how easy EntitySpaces can be used to work with the Compact Framework. Click here for a larger viewWhile creating the demo we were very impressed with VistaDB 3.0. VistaDB has some features that we found make it very attractive. First, VistaDB has some nice advantages over the Microsoft SQL Compact Edition. The VistaDB Namespace doesn't change when moving to the Compact Framework. The Microsoft Compact Edition, however, uses SqlCeClient instead of SqlClient, which makes it more difficult for developers to maintain a single codebase. The EntitySpaces architecture conveniently hides these low level issues from the developer, thereby isolating code from such provider quirks. Also, the same VistaDB database (the exact same physical file) will run on all environments with no loss of features or a lesser SQL syntax when running under the Compact Framework.

Having said that, the EntitySpaces Architecture does support the Microsoft SQL Compact Edition fully, and we will publishing the same demo application shown here for it very soon. We are just putting a few finishing touches on the EntitySpaces provider for the Microsoft SQL Compact Edition. The SQL supported under the Microsoft SQL Compact Edition is different than what is allowable under Microsoft SQL 2005. The EntitySpaces user of course will never realize these differences and that is one of the main strengths of EntitySpaces.

The EntitySpaces Mobile demo will be available for download Monday December 4th by 8:00 AM EST time. A link will be posted on this page.

 

 

 

 

 

 


- The EntitySpaces Team

posted on Saturday, December 02, 2006 10:08:43 PM (Eastern Standard Time, UTC-05:00)  #   
 Sunday, November 19, 2006

The EntitySpaces 1.5.2 Bets is now available for download. Below are the enhancements and fixes added to this release:

  • Full support for VistaDb 3.0
  • Compact Framework Providers for both Microsoft SQL Server and VistaDb
  • Full compliance with the DotNetNuke {objectQualifier} when using dynamic sql or stored procedures.
  • EntitySpaces can now be run without a config file. This is intended to help facilitate modular software development, and removes the situation where your end users are required to enter config entries. Below is an example of how to set your default connection programmatically


// Manually register a connection
esConnectionElement conn = new esConnectionElement();
conn.ConnectionString = "User ID=sa;Password=;Initial Catalog=Northwind;Data Source=localhost";
conn.Name = "GroovySQL";
conn.Provider = "EntitySpaces.SqlClientProvider";
conn.ProviderClass = "DataProvider";
conn.SqlAccessType = esSqlAccessType.DynamicSQL;
conn.ProviderMetadataKey = "esDefault";conn.DatabaseVersion = "2005";

// Assign the Default Connection
esConfigSettings.ConnectionInfo.Connections.Add(conn);
esConfigSettings.ConnectionInfo.Default = "GroovySQL";

// Use the code as usual
Employees e = new Employees();
if (e.LoadByPrimaryKey(1))
{
    e.Save();
}

int? i = e.EmployeeID;

  • Added [XmlIgnore] to hierarchical objects to prevent endless loops with self referencing relationships. This will be further refined again in our 1.6.0 release.
  • Added Lock/SyncLock in two places to protect static data

This is a full beta and all providers are included.

  1. This beta requires the new MyGeneration beta available on the MyGeneration homepage.
  2. The EntitySpaces beta can be found in the trial forum HERE
posted on Sunday, November 19, 2006 9:20:55 AM (Eastern Standard Time, UTC-05:00)  #   
 Thursday, November 09, 2006

So, you must be thinking "What's this EntitySpaces 1.5.2 release? we thought 1.6.0 was next?". The truth is we weren't originally planning to do a 1.5.2 release but it became apparent that this release needs to happen for several reasons. One of the main driving factors for this release is VistaDB 3.0, we plan to fully support VistaDB 3.0 before its official release. It is our hope that upon the next release of the VistaDB CTP there will be no issues preventing us from releasing the EntitySpaces DataProvider for VistaDB, indeed all of the coding is done for it already. We know the VistaDB team is working hard on their next CTP. 

Also, VistaDB runs under the Compact Framework and tonight we successfully compiled EntitySpaces under the Compact Framework as well. This means any device VistaDB runs on EntitySpaces will also. EntitySpaces should also now run under Mono but we have not tested that yet. About the only real problem encountered in getting EntitySpaces to compile under the Compact Framework was our custom configuration section logic and binary serialization. We will still maintain only one codebase and use #IFDEF's in our code to compile for the Compact Framework and without. We are focusing now upon getting EntitySpaces working clean on the Compact Framework. Part of this involves allowing EntitySpaces to run in configless mode which we will offer for both the Compact Framework and our main build. This will help those who might be developing for hosting environments and who need to have a hundred or so connections.

Also, futher support for DotNetNuke including the DNN Object Qualifier and the ability to pull the the connection string directly from the DNN config file are in the works. Of course, there will be a few fixes to address some issues that have been reported as well.

It is our thinking that the 1.5.2 release will be ship near the end of November or early December. Our 1.6.0 release is still all about ASP.NET DataBinding on steroids including hierarchical databinding. The EntitySpaces 1.6.0 roadmap should be published by the end of November and our thinking is that the 1.6.0 release will ship in early 2007. 

- The EntitySpaces Team

 

posted on Thursday, November 09, 2006 9:35:30 PM (Eastern Standard Time, UTC-05:00)  #