Monday, August 24, 2009

We just wanted to do a quick blog post and let everyone know that so far we are on track for the August 31st release date. We have almost finished adding the EntitySpaces universal concurrency checking code for provider independent programmers. Everything has to go through unit testing again but we’re very close now. This is a big release for us and this is going to be a very busy week for sure. Follow us on Twitter for more timely info ..

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 Silverlight application, 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.

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

posted on Monday, August 24, 2009 2:55:19 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0]
 Saturday, August 22, 2009

We have asked the ORMBattle.NET Team to rethink their test suite before we participate. We have not seen our performance numbers, have no idea what they might be as we cannot even compile the ORMBattle.NET solution. We still fully support what they are trying to do and will participate if these things are addressed. We looked at their tests last night and found some issues that we think need to be changed in order to make the tests valid. We were a little disappointed.

  • All of the “single” tests are using entire collections to load all of the data in a single fetch? We feel this tests nothing. All of the single tests should read one record at a time, then update/delete/add, then save. This would then appropriately indicate how fast can that ORM solution can work with a single “entity” or record of data. This is the case with most grids which then move to “edit” mode where the entire record needs to be fetched and then saved.
  • The use of Transactions is entirely wrong (described below).

Most of the tests, even the tests that test how fast an ORM solution can fetch data through a “Query” do so with a transaction declared and then within the declared transaction fetch the data “n” number of times? Who declares a transaction when they perform their queries? With EntitySpaces this would open a connection and then hold that connection open through the life of the test. Great for us, but this doesn’t test connection pooling nor does it simulate how many times you can do a real query with complete setup and teardown.

Finally, even the tests that perform the single operation of updating a single record (add/edit/delete) do so in a loop within a declared transaction? There is no need to have a transaction declared to get performance numbers on updating a single record. And again, as we have said above, all of the tests that are supposed to be indicating how fast an ORM solution can work with single records are very flawed as they use collections. If an ORM vendor has no single entity that can read/write then they should have to declare a collection each time to load the single row, change it, and then save it using their collection as a single entity.

Some vendors like Open Access don’t even implement the single tests?

protected override void InsertSingleTest(int count)
{
   Log.Error("Not implemented.");
}

protected override void UpdateSingleTest()
{
   Log.Error("Not implemented.");
}

protected override void DeleteSingleTest()
{
   Log.Error("Not implemented.");
}

yet still seem to get a great score in that area?  Even the ORMBattle.NET test results grid lumps everything into DataModification? There should be separate collection and single entity scores. But as the tests stand now there are no real single entity reading / writing tests to even evaluate.

So, in summary, we are asking the ORMBattle.NET Team for real world tests for single entity reading and writing without transactions open (that allow for special optimized tweaks when you open and hold a connection open). The same goes for “Query” testing, these should not be done nested inside a transaction.

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 Silverlight application, 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.

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

posted on Saturday, August 22, 2009 6:35:19 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0]
 Saturday, August 15, 2009

ORMBattle.NET is devoted to direct ORM comparison. This site is actually run by one of the ORM vendors but we still want to take our shot at it.

 

Vote Here For EntitySpaces to the Next ORM product evaluated ==> ORM BATTLE.NET

 

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 Silverlight application, 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.

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

posted on Saturday, August 15, 2009 7:24:46 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0]
 Tuesday, August 11, 2009

Things are going great. We now have all of our data providers upgraded and compiling clean, including the Compact Framework providers. We have many users working fine with our Sybase support so we are very pleased on how our Sybase support is being received. This is just a quick post to let you know we have added the Having clause to fill out our DynamicQuery API.

Here is a sample query (this might not make sense as a real query, this was just for testing the syntax, the query did return data however).

EmployeeQuery q = new EmployeeQuery();
q.Select(q.EmployeeID, q.Age.Sum().As("TotalAge"));
q.Where(q.EmployeeID.IsNotNull());
q.GroupBy(q.EmployeeID);
q.Having(q.Age.Sum() > 5);
q.OrderBy(q.EmployeeID.Descending);

EmployeeCollection coll = new EmployeeCollection();
if (coll.Load(q))
{

}

This resulting SQL is shown below:

SELECT [EmployeeID] AS 'EmployeeID',SUM([Age]) AS 'TotalAge'  FROM
[ForeignKeyTest].[dbo].[Employee]
WHERE[EmployeeID] IS NOT NULL
GROUP BY [EmployeeID]
HAVING SUM([Age]) > @Age2
ORDER BY [EmployeeID] DESC

Our DynamicQuery API has such terrific enhancements coming in ES2009 Q3. Also, our release dates have been posted on our Roadmap. Start making your plans today …

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 Silverlight application, 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.

 

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

posted on Tuesday, August 11, 2009 9:00:51 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0]
 Thursday, August 06, 2009

This information is on our Roadmap page which can be seen HERE.

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 Silverlight application, 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.

 

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

posted on Thursday, August 06, 2009 10:49:04 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0]
 Sunday, August 02, 2009
Shout it kick it on DotNetKicks.com

image

We are very excited to announce our Sybase SQL Anywhere support available with this release. We currently support Sybase SQL Anywhere 11 (versions 11.0.0.1490 and 11.0.1.2044). Our assemblies are bound to the 11.0.1.2044 version. However, if you are using the older 11.0.0.1490 version see this post on our forums. Swapping your SQL Anywhere provider version only takes a minute or two. We ship two providers for Sybase, a regular EntitySpaces provider for Sybase network server/personal server, and one for the Compact Framework. Both of these are available in this alpha release. EntitySpaces (the application) is available in two modes; a Visual Studio Add-In which is available from the Visual Studio “Tools” menu and the “stand alone” application available from your EntitySpaces 2009 menu after installation.

Our Sybase support in this initial release is already very rich. We support Sybase autoincrement columns, timestamps for concurrency, and both dynamic and stored procedures modes for updating your Sybase housed data. There is a new template included with this release that will generate your Sybase CRUD stored procedures if you want to use stored procedures for your CRUD operations. This isn’t required however, EntitySpaces can run with or without stored procedures. This is our first release with Sybase support so please let us know via the forums how the Sybase support is working for you. We’ve done a pretty good job of testing and will fix any bugs reported on our forums.

We already have a customer who is going to be writing a Silverlight application using EntitySpaces 2009 and Sybase, very cool stuff. Customers can find this release under our Products –> Downloads menu. The source code for customers who purchased source code should be published later on this evening and be available by Monday morning at the latest. UPDATE – 2009-08-07: We have posted a Trial version of this Alpha on our Trial Download page.

This Alpha Release only includes EntitySpaces providers for SQL Server and Sybase. The EntitySpaces 2009 Q3 enhancements will be rolled into the other providers and be available with the upcoming Beta Release. Our current Production Release (with all providers) is EntitySpaces 2009.1.0209.0. It is available to Customers on the Products Downloads page, and as a Trial version on the Trial Download page. For current customers wishing to try the EntitySpaces provider for Sybase, or want to get a jump start on the Q3 enhancements for SQL Server, be sure to read the installation instructions and release notes for the Alpha.

New EntitySpaces Users


If you are new to EntitySpaces watch our video demonstrating how easy it is to create your first EntitySpaces application and get up and running quickly. Click the video on the left to watch the video.

getstarted


Be sure and read through our Getting Started PDF file. You can click on the image to the left or click on the link on your EntitySpaces 2009 menu after installation. This document is pretty short and if you take the time to read through it you will save yourself time in the end. So take a look at this very valuable document.

Also, be sure and register on our forums. We have created two new areas specifically for our Sybase providers. If the issue you are having is specific to one of our Sybase providers, such as the incorrect SQL being generated (which isn’t very likely), post a note in the proper Sybase forum. Of course, all other “How do I ?” questions you can ask in the proper area on our forums.

Finally, on your EntitySpaces 2009 menu after installation you will see Windows.Forms, ASP.NET, and Silverlight programming samples that will compile right out of the box. They are set to run against the Microsoft SQL Northwind database. Even if that is not the database you are running they are great samples to look at. The ASP.NET samples also use our esDataSource control. So if you are looking for example code be sure and check the sample applications found in your EntitySpaces 2009 program menu entry.

Other Features

There are some other very nice features in this alpha release. Our proxies now support something we call “Compact XML” and can be used whenever you are using both our Client side and Server Side proxies together and avoiding the middle man (that is the Visual Studio Generated proxies as we do in our Silverlight demo). We have updated our online Silverlight example and it is now using our Compact XML mode. As a side note, Silverlight supports something called Binary XML serialization out of the box with only a config file change required.

There is also a new feature in the Settings Tab that lets you control what happens on a double click a template in the Template tab. You can either have the double click launch the template for editing, or for execution, or for execution with the last known settings. The EntitySpaces Universal Concurrency checking mechanism IS NOT in this release, but it will be in our upcoming beta.

Our next step is going to be to rapidly upgrade the rest of our data providers, implement our “EntitySpaces Universal Concurrency” feature for database independent concurrency handling, make our project files path relative, and squeeze in more features from our Q3 Wish List forum. Things are going to move very rapidly. After next weeks team meeting we should be able to publish the target release our first beta, including what features will be included, and finally, publish the RTW date for the official release of  EntitySpaces 2009 Q3.

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 Silverlight application, 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.

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

 

posted on Sunday, August 02, 2009 2:44:47 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0]
 Tuesday, July 28, 2009

This little gem was brought up by one of our customers, Paul_IBSoftware, and it looked like fun to implement so we snuck it into our Q3 release. Nothing like getting a suggestion and having it in the product the same day. Basically, we had the SQL conjuctions AND and OR but we didn’t have anyway to indicate AND NOT or OR NOT but that is no longer true, see the example below.

VB.NET

Dim q As New EmployeesQuery()
q.es.Top = 1
q.Where(q.EmployeeID = 1 And Not (q.LastName = "goofy"))
q.Load()

Notice you can now use And Not/Or Not in your query syntax. This will yield the following SQL syntax.

SELECT  TOP 1 *
FROM [Employees]
WHERE ([EmployeeID] = @EmployeeID1 AND NOT [LastName] = @LastName2)

C#

You can do this in C# too, however this is one case where the VB.NET syntax reads better than the C# syntax. Take a look at the sample below.

EmployeesQuery q = new EmployeesQuery();
q.es.Top = 1;
q.Where(q.EmployeeID == 1 && ! (q.LastName == "googy"));
q.Load();

Granted, a C# developer would probably never think of that syntax, but it yields the exact same SQL as above. Probably a C# developer would write it as below

EmployeesQuery q = new EmployeesQuery();
q.es.Top = 1;
q.Where(q.EmployeeID == 1 && (q.LastName != "googy"));
q.Load();

The above query would product the following SQL.

SELECT  TOP 1 *
FROM [Employees]
WHERE ([EmployeeID] = @EmployeeID1 AND [LastName] <> @LastName2)

Summary

The EntitySpaces 2009 Q3 DynamicQuery is going to blow your socks off. We are so excited about this release, things are moving very quickly too.

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 Silverlight application, 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.

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

posted on Tuesday, July 28, 2009 6:31:17 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0]
 Monday, July 27, 2009
kick it on DotNetKicks.com

We have our Sybase SQL Anywhere implementation working quite well now. We are releasing a new alpha on August 3rd that will come with a new provider for Sybase SQL Anywhere including a Compact Framework provider as well for Sybase mobile development. We have been developing and testing with SQL Anywhere version 11. Everything is working great including autoincrement keys, concurrency checking, and so on. We haven't tested our stored procedures yet but should have that work completed by August 3rd. Remember Sybase fans, EntitySpaces runs under Mono as well.

Having never really used Sybase before we must say it really is a very full featured database and they have worked with us very well. We basically have a red phone we can pick up and get right to technical support, fantastic! Sybase really seems to be focused on customer service more so than most companies we’ve worked with, maybe that’s part of why Sybase has announced terrific earnings for Q2 of this year, who else can say that? We will be taking a look at supporting their Ultra Light version as well. Sybase is a very serious contender in the database world, you will be hearing more from us on this subject in the future. If you don’t know much about Sybase click on some of the links in this post, we think you will be impressed.

This should be our last Alpha version. Soon we will be upgrading all our providers to support the new features we've implemented (with some still yet to be added). We will then provide a beta release that will be made available to the general public as a trial version as we head down the home stretch for EntitySpaces 2009 Q3.

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 Silverlight application, 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.

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

posted on Monday, July 27, 2009 9:43:51 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0]
 Tuesday, July 21, 2009

We thought we would use this blog post to report more progress on our EntitySpaces 2009 Q3 release. However, before we continue we want to point out that our current production release is EntitySpaces Q1 2009.1.0209.0 and it is available now, it is also very stable (as usual). Okay, so here is some of the new functionality, we are working through our Q3 Wish List forum posts.

image

In the above image we have selected the EntitySpaces 2009 Metadata tab. We have highlighted two areas in the image for purposes of this post. The red box is a .NET PropertyGrid control and we use this now instead of what we used to use, which was a .NET DataGrid. Not only does it look better and allow us to group data by functionality, but it also allows for easy editing. The blue box highlights certain fields that you can edit directly in the metadata. Notice that you can edit the “Alias” directly in the Metadata. Also, there is an Exclude flag which you can set to true to indicate that you want this column skipped entirely during code generation purposes. There is also a new flag called IsUniversalConcurrency which you can set on any integer type field (I can see econner jumping for joy already!). This will allow you to have exact matching schema’s across multiple databases and still have concurrency checking. The reason this is needed is Microsoft SQL’s Timestamp for instance is not really compatible with other database systems, or said better there really is no universal concurrency checking built into dbms systems so we will provide one for you. Finally, we have IsCustomAutoKey and CustomAutoKeyText, these will replace the current way that Oracle users (and possibly others) have to provide key/value pairs in our user metadata. We will automatically convert your current UserData.xml files for you to support his new approach. All of our Metadata is now presented this way (not just column information).

What is nice about this new approach is that we can expand it easily in the future and behind the scenes any values that you edit end up in the user metadata just as it would if you were typing in key/value pairs only it’s so much easier. We are also considering making IsInPrimaryKey editable so that you can make tables without primary keys appear as though they had them.

Also, we have eliminated the problem that prevented you from daisy chaining queries when joins were involved.

We have also flushed out the DynamicQuery API such that you have no operator precedence issues, for instance.

query.Where(42 > query.Age);

or

query.Where(query.Age < 42);

The same holds true with our mathematical operators as well.

query.Select(“Wow” + query.FirstName + “Cool”); // notice the string “Wow” comes first

or

query.Select(100 * query.Age);  // Notice the 100 comes first

Progress is moving very rapidly and we are still passing at 100% in our unit tests (including a bunch of new tests that have been added).

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 Silverlight application, 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.

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

posted on Tuesday, July 21, 2009 6:42:50 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0]
 Thursday, July 16, 2009
kick it on DotNetKicks.com

We have pushed our EntitySpaces Silverlight application up so you can run it and take a look at it. We decided to compile it under the Silverlight 3 toolset so it requires Silverlight 3 to run it. We did this to make sure we are compatible. Silverlight 3 is RTM now and you can download the Visual Studio tools for it HERE but you do not need these to run the demo, just to develop Silverlight 3 applications. There is a lot of code posted in this blog post but we thought you might really want to know how this stuff works, it’s not that hard to understand if you take the time to look at the code. The online demo can be found here ==> DEMO

image

You can add rows and edit rows and then save the data. We are using the Microsoft SQL Northwind database, specifically the Employees table. When you search you can search on the first name or last name fields. The purpose of this demo is not to make a really cool Silverlight UI, but to show how easy it is to use EntitySpaces to write a Silverlight application. There is one glitch when editing data. You need to move off of the selected row for your edits to “take”. This is a Silverlight issue and not an EntitySpaces Issue. The demo is included in our current alpha, however the version shown here is fancier. (It will be in the next release as shown above).

The EntitySpaces Silverlight Demo uses our EntitySpaces proxies on both sides of the conversation. The client side proxies run under Silverlight and our server side proxies run on the server. The Silverlight application hits our WCF service to fetch the data.

The WCF Service

This is what the WCF Service looks like including the Interface. The Interface for the service is shown below. Notice we are returning and taking the EntitySpaces Proxy Stub classes as parameters. However, we pass the EntitySpaces DynamicQuery to the server in string form. The EntitySpaces DynamicQuery is now fully functional under Silverlight and requires only a single 49k assembly which will automatically download with your Siverlight application.

using System.ServiceModel;
 
using BusinessObjects;
 
namespace EntitySpaces.SilverlightApplication.Web
{
    [ServiceContract]
    public interface INorthwind
    {
        [OperationContract]
        EmployeesCollectionProxyStub GetEmployees(string employeesQuery);
 
        [OperationContract]
        EmployeesCollectionProxyStub SaveEmployees(EmployeesCollectionProxyStub collection);
    }
}
 
The implementation class is shown below. Notice in GetEmployees() we deserialize the incoming query (passed as a string) with a single one-line call into a full server side query that we can execute. We then use that query to load our collection, and finally wrap it with a proxy collection and return it. The Save() method is ridiculously simple and powerful. Notice that we merely access the incoming proxies “Collection” property (which is a full EmployeesCollection class) and call save on it. Then we simply return the very same proxy that was sent to us as the incoming parameter. Try clicking the Add button in our demo a few times and then press the Save button. Notice the auto identity columns are immediately reflected in the grid. These are returned automatically via our save method. This is an incredibly powerful and easy way to create Silverlight applications. The row state, including added, modified, and deleted, are automatically maintained for you. All you have to do is call save.
 
using System;
using System.Collections.Generic;
using System.ServiceModel.Activation;
 
using BusinessObjects;
 
namespace EntitySpaces.SilverlightApplication.Web
{
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    public class Northwind : INorthwind
    {
        #region INorthwind Members
 
        public EmployeesCollectionProxyStub GetEmployees(string serializedQuery)
        {
            List<Type> types = new List<Type>();
            types.Add(typeof(EmployeesQuery));
 
            EmployeesQuery employeesQuery = EmployeesQuery.SerializeHelper.FromXml(
                serializedQuery, typeof(EmployeesQuery), types) as EmployeesQuery;
 
            EmployeesCollection employeesCollection = new EmployeesCollection();
            if (employeesCollection.Load(employeesQuery))
            {
                EmployeesCollectionProxyStub proxy = new EmployeesCollectionProxyStub(employeesCollection);
                return proxy;
            }
 
            return null;
        }
 
        public EmployeesCollectionProxyStub SaveEmployees(EmployeesCollectionProxyStub collection)
        {
            if (collection != null)
            {
                collection.GetCollection().Save();
                return collection;
            }
 
            return null;
        }
 
        #endregion
    }
}


The Silverlight Page

Our Page.xaml file looks like this. A lot of this is just noise like setting up the buttons and such. The part you are interested in is the <data:DataGrid.Columns> section where we manually setup the columns we want to display in the grid. We could have used AutoGenerateColumns=“True” however. For the two date columns we use a DataGridTemplateColumn in order to hookup the fancy date editing control. We also set the EmployeeID column to read only so that users cannot edit the primary key.

<UserControl xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"  xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"  x:Class="EntitySpaces.SilverlightApplication.Page"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
 
    <Grid Background="Black" >
 
        <Grid.RowDefinitions>
            <RowDefinition Height="50"></RowDefinition>
            <RowDefinition Height="*"></RowDefinition>
            <RowDefinition Height="50"></RowDefinition>
        </Grid.RowDefinitions>
 
        <Grid Grid.Row="0" Margin="7">
 
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="100"></ColumnDefinition>
                <ColumnDefinition Width="300"></ColumnDefinition>
                <ColumnDefinition Width="*"></ColumnDefinition>
                <ColumnDefinition Width="240"></ColumnDefinition>
                <ColumnDefinition Width="75"></ColumnDefinition>
            </Grid.ColumnDefinitions>
            
            <HyperlinkButton Grid.Column="0" NavigateUri="http://www.entityspaces.net" TargetName="New"><Image Source="EntitySpaces_Logo.jpg" Grid.Column="0" /></HyperlinkButton>
            <TextBlock Name="SearchTextBlock" Grid.Column ="1" Text="EntitySpaces 2009 Silverlight Demo" Foreground="Yellow" FontSize="14" Margin="10,5,10,5" VerticalAlignment="Center"></TextBlock>
            <ProgressBar Name="WorkingBar" Grid.Column="2" Foreground="Yellow" Background="Black" Value="0" Maximum="100" Margin="2,2,2,2" />
            <TextBox Name="SearchTextBox" Text="Enter Criteria Here" Grid.Column="3" Margin="20,0,20,0" Padding="10,5,10,5" FontSize="14" GotFocus="SearchTextBox_GotFocus"></TextBox>
            <Button Name="SearchButton" Content="Search" Grid.Column="4" FontSize="14" Click="SearchButton_Click"></Button>
        </Grid>
 
 
 
        <Grid Grid.Row="1" Margin="7">
            <data:DataGrid Name="EmployeesDataGrid" AutoGenerateColumns="False" >
 
                <data:DataGrid.Columns>
 
                    <data:DataGridTextColumn Binding="{Binding EmployeeID}" Header="Employee ID" IsReadOnly="True" />
                    <data:DataGridTextColumn Binding="{Binding FirstName}" Header="First Name" />
                    <data:DataGridTextColumn Binding="{Binding LastName}" Header="Last Name" />
                    <data:DataGridTextColumn Binding="{Binding HomePhone}" Header="Home Phone" />
                    <data:DataGridTextColumn Binding="{Binding City}" Header="City" />
 
                    <data:DataGridTemplateColumn Header="Hire Date" Width="160">
                        <data:DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <TextBlock Text="{Binding HireDate, Mode=OneWay, Converter={StaticResource ShortDateConverter}}" VerticalAlignment="Center" Margin="2"/>
                            </DataTemplate>
                        </data:DataGridTemplateColumn.CellTemplate>
                        <data:DataGridTemplateColumn.CellEditingTemplate>
                            <DataTemplate>
                                <controls:DatePicker SelectedDate="{Binding HireDate, Mode=TwoWay}" />
                            </DataTemplate>
                        </data:DataGridTemplateColumn.CellEditingTemplate>
                    </data:DataGridTemplateColumn>
 
 
                    <data:DataGridTemplateColumn Header="Birth Date" Width="160">
                        <data:DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <TextBlock Text="{Binding BirthDate, Mode=OneWay, Converter={StaticResource ShortDateConverter}}" VerticalAlignment="Center" Margin="2"/>
                            </DataTemplate>
                        </data:DataGridTemplateColumn.CellTemplate>
                        <data:DataGridTemplateColumn.CellEditingTemplate>
                            <DataTemplate>
                                <controls:DatePicker SelectedDate="{Binding BirthDate, Mode=TwoWay}" />
                            </DataTemplate>
                        </data:DataGridTemplateColumn.CellEditingTemplate>
                    </data:DataGridTemplateColumn>
 
                </data:DataGrid.Columns>
 
            </data:DataGrid>
        </Grid>
 
        <Grid Grid.Row="2" Margin="7">
 
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"></ColumnDefinition>
                <ColumnDefinition Width="75"></ColumnDefinition>
                <ColumnDefinition Width="15"></ColumnDefinition>
                <ColumnDefinition Width="75"></ColumnDefinition>
                <ColumnDefinition Width="15"></ColumnDefinition>
                <ColumnDefinition Width="75"></ColumnDefinition>
            </Grid.ColumnDefinitions>
 
            <Button Name="AddButton" Content="Add" Grid.Row="2" Grid.Column="1" FontSize="14" Click="AddButton_Click" ></Button>
            <Button Name="SaveButton" Content="Save" Grid.Row="2" Grid.Column="3" FontSize="14" Click="SaveButton_Click" ></Button>
            <Button Name="ClearButton" Content="Clear" Grid.Row="2" Grid.Column="5" FontSize="14" Click="ClearButton_Click" ></Button>
        </Grid>
 
    </Grid>
</UserControl>

 

Our Page.xaml.cs file is shown below. Take a look at the SearchButton_Click event. We build the EntitySpaces DynamicQuery and call the service.GetEmployeesAsync() method passing in the query in string form. In the service_GetEmployeesCompleted() method we access our EmployeesCollectionProxyStub class which was returned to us in the “e.Result” variable. However, now we are working with the client side lightweight proxy class. The interesting thing about this approach is that we are NOT using the Visual Studio generated proxies. Our proxies are smart and maintain row state, and they are going to get even smarter. This approach makes EntitySpaces a terrific architecture for building your Silverlight applications. The SaveButton_Click is also incredibly simple. The timer stuff you see is just to make the fancy progress bar work in the demo.

using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media.Animation;
 
using EntitySpaces.SilverlightApplication.NorthwindClient;
using Proxies;
 
 
namespace EntitySpaces.SilverlightApplication
{
    public partial class Page : UserControl
    {
        private NorthwindClient.NorthwindClient service = new NorthwindClient.NorthwindClient();
        private Proxies.EmployeesCollectionProxyStub employees;
        private Storyboard Timer = new Storyboard();
        private int RecordsAdded;
 
 
        public Page()
        {
            InitializeComponent();
            Timer.Completed += new EventHandler(Timer_Completed);
            Timer.Duration = TimeSpan.FromMilliseconds(2);
        }
 
        private void SearchButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Proxies.EmployeesQueryProxyStub q = new Proxies.EmployeesQueryProxyStub("emp");
 
                q.Select(q.EmployeeID, q.FirstName, q.LastName, q.HomePhone, q.HireDate, q.BirthDate, q.City);
                q.Where(
                    q.FirstName.Like("%" + SearchTextBox.Text + "%") |
                    q.LastName.Like("%" + SearchTextBox.Text + "%"));
                q.OrderBy(q.LastName.Ascending);
 
                service.GetEmployeesCompleted += new EventHandler<GetEmployeesCompletedEventArgs>(service_GetEmployeesCompleted);
                service.GetEmployeesAsync(Proxies.EmployeesQueryProxyStub.SerializeHelper.ToXml(q));
 
                WorkingBar.Value = 0;
                Timer.Begin();
            }
            catch (Exception exc)
            {
                Console.WriteLine(exc.StackTrace);
            }
        }
 
        void service_GetEmployeesCompleted(object sender, GetEmployeesCompletedEventArgs e)
        {
            WorkingBar.Value = 100;
            Timer.Stop();
            
            if (e.Result != null)
            {
                employees = e.Result;
                EmployeesDataGrid.ItemsSource = employees.Collection;
            }
        }
 
        private void ClearButton_Click(object sender, RoutedEventArgs e)
        {
            SearchTextBox.Text = "";
            employees = null;
            EmployeesDataGrid.ItemsSource = null;
        }
 
        private void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (employees == null) return;
 
                WorkingBar.Value = 0;
                Timer.Begin();
 
                service.SaveEmployeesCompleted += new EventHandler<SaveEmployeesCompletedEventArgs>(service_SaveEmployeesCompleted);
                service.SaveEmployeesAsync(employees);
            }
            catch (Exception exc)
            {
                Console.WriteLine(exc.StackTrace);
            }
        }
 
        private void AddButton_Click(object sender, RoutedEventArgs e)
        {
            if (employees == null)
            {
                employees = new EmployeesCollectionProxyStub();
                EmployeesDataGrid.ItemsSource = employees.Collection;
            }
 
            if (RecordsAdded++ < 5)
            {
                EmployeesProxyStub newEmp = new EmployeesProxyStub();
                newEmp.FirstName = "Scott";
                newEmp.LastName = "Schecter";
 
                employees.Collection.Add(newEmp);
            }
        }
 
        void service_SaveEmployeesCompleted(object sender, SaveEmployeesCompletedEventArgs e)
        {
            try
            {
                WorkingBar.Value = 100;
                Timer.Stop();
 
                RecordsAdded = 0;
 
                employees = e.Result;
                EmployeesDataGrid.ItemsSource = employees.Collection;
            }
            catch (Exception exc)
            {
                Console.WriteLine(exc.StackTrace);
            }
        }
 
        private void SearchTextBox_GotFocus(object sender, RoutedEventArgs e)
        {
            if (SearchTextBox.Text == "Enter Criteria Here")
            {
                SearchTextBox.Text = "";
            }
        }
 
        void Timer_Completed(object sender, EventArgs e)
        {
            WorkingBar.Value++;
            Timer.Begin();
 
            if (WorkingBar.Value > 100)
            {
                WorkingBar.Value = 1;
            }
        }
    }
}

Rather than repeat of bunch of content from previous posts, here are two posts that will help you further understand how we created the entire solution.

1) How we generated the lightweight client side proxies.

2) How we built the application and informed Visual Studio to use our proxies rather than generate proxies for us.

Be sure when you execute the “Generated Master” template to check the “Serializable Queries” checkbox on the advanced tab. Again, the demo is included in the latest alpha. We are even adding a new checkbox that will “scrunch” the XML when it goes over the wire so that your packets are much smaller. The XML will send all of your fields as “a1”, “a2”, “a3” and so on rather than “EmployeeID”, “FirstName”, “LastName”. This will make a big difference when sending large chunks of data from client to server and back again. Of course, we only send the columns that actually have data (non null/default) so your XML will be very tiny. This will not impact your proxies, they of course will still have your nice property names.

Well, that’s it for now. We are not only working on Silverlight and Proxies, we are also working through the Q3 Wish List as well.

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 Silverlight application, 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.

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

posted on Thursday, July 16, 2009 10:42:46 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0]