Sunday, February 10, 2008

If you are an EntitySpaces customer, then you know how serious we take our forum support. When issues or feature requests are posted in our forums, we create a ticket in our Trac system. This Trac ticket will have a description of the issue, offer some thoughts and comments on it, and finally tie the ticket back to the originating forum post via a URL. Before each EntitySpaces release, the EntitySpaces team will, in one of our weekly Skype meetings, go through the Trac system and create a milestone, which typically consists of several key new features and a list of issues as reported in the forums. Below is a (partial) snapshot of our first ES2008 Beta milestone, however, the 0315 date is not to be taken literally, it could be before or after that date.

The key to the success of EntitySpaces lies in it's ease of use, which in large part comes from an elegant and intuitive API. However, none of that would matter if it wasn't backed by excellent forum support, tracking issues as they are reported, and extensive unit testing. Sometime in the ES2008 cycle we will do a blog post describing how our unit testing methodology is used to deliver a rock solid architecture to our customers.

image 

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, 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, February 10, 2008 10:48:33 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0]
 Thursday, February 07, 2008
kick it on DotNetKicks.com

We're busy working on EntitySpaces 2008 (ES2008) and thought we would demonstrate to you how subqueries will work. If you are familiar with our Join syntax then subqueries will feel like a perfect extension. The EntitySpaces 2008 architecture allows subqueries on the Select, the Where, the From, and the Join statement. Before we look at subqueries take a moment to review how our join syntax works. The EntitySpaces DynamicQuery API has proven to be very popular, so much so that other architectures are following suit.

EntitySpaces Join Syntax Review

Notice that we create three query objects and then relate them through InnerJoins and finally ask the CustomerCollection to load the query.

CustomerQuery cust = new CustomerQuery ("c");
OrderQuery order = new OrderQuery ("o");
OrderItemQuery item = new OrderItemQuery ("oi");

cust.Select(cust.CustomerName, (item.Quantity * item.UnitPrice).Sum().As("TotalSales"));
cust.InnerJoin(order).On(order.CustID == cust.CustomerID);
cust.InnerJoin(item).On(item.OrderID == order.OrderID);
cust.GroupBy(cust.CustomerName);
cust.OrderBy("TotalSales", esOrderByDirection.Descending);

CustomerCollection coll = new CustomerCollection ();
coll.Load(cust);

Pretty sweet and that is supported in ES2007 which is shipping now. But we're just getting started. Now let's look at some subquery samples.

EntitySpaces SubQuery in the Select Statement

This subquery determines the Maximum Unit Price for each order in the system.

OrdersQuery orders = new OrdersQuery("orders");
OrderDetailsQuery details = new OrderDetailsQuery("details");

orders.Select
(
    orders.OrderID,
    orders.OrderDate,
    details.Select(details.UnitPrice.Max()).Where(orders.OrderID == details.OrderID).As("MaxUnitPrice")
);
OrdersCollection coll = new OrdersCollection();
coll.Load(orders);

The resulting SQL generated by our SqlClientProvider is as follows.

SELECT orders.[OrderID],orders.[OrderDate],
(
    SELECT MAX(details.[UnitPrice]) AS 'UnitPrice' 
    FROM [Northwind].[dbo].[Order Details] details
    WHERE orders.[OrderID] = details.[OrderID]
) AS MaxUnitPrice 
FROM [Northwind].[dbo].[Orders] orders

The resulting data is as follows:

OrderID     OrderDate               MaxUnitPrice
----------- ----------------------- --------------
10248       1996-07-04 00:00:00.000    34.80
10249       1996-07-05 00:00:00.000    42.40
10250       1996-07-08 00:00:00.000    42.40
10251       1996-07-08 00:00:00.000    16.80
10252       1996-07-09 00:00:00.000    64.80
10253       1996-07-10 00:00:00.000    16.00
10254       1996-07-11 00:00:00.000    19.20
10255       1996-07-12 00:00:00.000    44.00
10256       1996-07-15 00:00:00.000    26.20

EntitySpaces SubQuery in the From Clause

Now let's look at using a subquery used in the From clause which returns the average freight per company.

OrdersQuery o = new OrdersQuery("o");

CustomersQuery c = new CustomersQuery("c");
c.Select(c.CompanyName, c.Country, o.Freight);
c.From
    (
        o.Select(o.CustomerID, o.Freight.Avg()).GroupBy(o.CustomerID)
    ).As("s");
c.InnerJoin(c).On(c.CustomerID == o.CustomerID);

CustomersCollection coll = new CustomersCollection();
coll.Load(c);

The resulting SQL generated by our SqlClientProvider is as follows.

SELECT c.[CompanyName],c.[Country],s.[Freight] 
FROM
(
    SELECT o.[CustomerID],AVG(o.[Freight]) AS 'Freight' 
    FROM [Northwind].[dbo].[Orders] o
    GROUP BY o.[CustomerID]
) AS s
INNER JOIN [Northwind].[dbo].[Customers] c
ON c.[CustomerID] = s.[CustomerID]

The resulting rows look like this:

CompanyName                              Country         Freight
---------------------------------------- --------------- -------
Alfreds Futterkiste                      Germany         37.5966
Ana Trujillo Emparedados y helados       Mexico          24.355
Antonio Moreno Taquería                  Mexico          38.36
Around the Horn                          UK              36.3038
Berglunds snabbköp                       Sweden          86.64
Blauer See Delikatessen                  Germany         24.0371
Blondesddsl père et fils                 France          56.6963
Bólido Comidas preparadas                Spain           63.7233
Bon app'                                 France          79.8747
Bottom-Dollar Markets                    Canada          56.7107

EntitySpaces SubQuery in the Where Clause

Here we have returned a list of countries where customers live where there is no supplier located in that country. Here we pass a subquery to the NotIn() operator.

SuppliersQuery supp = new SuppliersQuery("supp");
supp.es.Distinct = true;
supp.Select(supp.Country);

CustomersQuery cust = new CustomersQuery("cust");
cust.es.Distinct = true;
cust.Select(cust.Country);
cust.Where(cust.Country.NotIn(supp));

CustomersCollection coll = new CustomersCollection();
coll.Load(cust);

The resulting SQL generated by our SqlClientProvider is as follows:

SELECT DISTINCT cust.[Country] 
FROM [Northwind].[dbo].[Customers] cust
WHERE cust.[Country] NOT IN
(
    SELECT DISTINCT supp.[Country] 
    FROM [Northwind].[dbo].[Suppliers] supp
)

The resulting rows look like this:

Country
---------------
Argentina
Austria
Belgium
Ireland
Mexico
Poland
Portugal
Switzerland
Venezuela

Although not shown here it is also possible to use a subquery in the Join statement. Of course, subqueries can be nested in various ways too. We hope this gives you a glimpse of what is coming in ES2008. We are making great progress. The beauty of course is this will work on all of the databases we support.

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, 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 Thursday, February 07, 2008 10:31:21 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0]
 Saturday, February 02, 2008
kick it on DotNetKicks.com


  

That's right ... "EntitySpaces running under Mono on Linux using MySQL as the backend".

 

 

If you are an EntitySpaces customer, you can now travel anywhere. From Windows, to Mono/Linux solutions, to the Compact Framework and all kinds of wireless devices, to Web Applications including "Medium Trust" support, or to high-end Enterprise Applications, EntitySpaces can take you there. EntitySpaces is truly a tiny, lightweight, powerful architecture for the Microsoft.NET Framework, and uses zero reflection. If you are a Mono developer, EntitySpaces is a terrific architecture for you. With it, you can work on both sides of the isle. Our database independence can free you from most of the complexities of supporting many types of databases, including those that run under Mono, such as MySQL and VistaDB. No longer will you have to invent new architectures with every new challenge that comes down the road.

Our contest winner goes by the title Pro.Coder, and is a independent contractor. We have received his entry to our Mono contest, and were quite pleased. Pro.Coder sent us a DVD with the EntitySpaces demo running under Mono. Thank you Pro.Coder, you did an excellent job. An image of it is shown below. Pro.Coder added the CRUD and DynamicQuery Join examples, to satisfy our contest requirements.

 

image

Below are some comments we received with Pro.Coder's DVD on how he got our EntitySpaces Demo to run under Mono ...

As for EntitySpaces on Mono application development, I did the following Steps:

  1. Download and Install Latest Version My Generation 
  2. Download and Install Latest Trial Version Of EntitySpaces 2007 
  3. Download and Install Latest Version of MySQL Community Edition
  4. Download and Version 5.0.7.0 of MySQL .net/Connector (Otherwise EntitySpaces gives Version conflict error)
  5. Download and Install Latest Version of Mono for windows
  6. Download and Install Latest Version VMware Player
  7. Download Mono Suse 10.2 VMware Virtual Machine
  8. Imported the Northwind database to MySQL from Sql Server
  9. Created CRUD procedures for MySQL Northwind database using My Generation EntitySpaces Template

Once all the installation was done, I was ready develop EntitySpaces on Mono. I used Visual Studio 2005 to develop, and used Mono to test it first on Windows. Once everything was working, I used VMware player and Mono Suse 10.2 VMware Virtual Machine to test it on Linux.

Instead of developing an application from scratch, I used the VB.net example that was shipped with the Trial version of EntitySpaces 2007. The first thing I did was to make EntitySpaces use the configless connection string support, which was very easy. Then, I started the build and debug process. From the features I have tested, CRUD process and Dynamic Query all work fine. While modifying the example application, the main issues I faced were:

Data Binding and Windows Forms
Binding the Windows Forms DataGrid Control to a Data Source
Binding Class
BindingContext Class
BindingsCollection Class 

I think many methods and properties are not yet supported on Mono. Maybe they are supported, and I just have to do some tweaking. I'm not sure. I have not yet gone through the Mono documentation. Grid.DataSource = EntityCollection gives a type conversion error, so I used CreateColumnsForBinding. Even after using it, I still got type conversion error. I'm not sure what exactly CreateColumnsForBinding is for. I thought it should correct it. So, as it didn't work, I did the next best thing, and added a ToDataTable() method to collection class and used it to bind to the grid.

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, 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 Saturday, February 02, 2008 11:02:11 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0]
 Thursday, January 31, 2008
kick it on DotNetKicks.com

If you are a CodeSmith guru, and well versed in writing CodeSmith templates, you are the kind of person we are looking for. We have a set of templates written for MyGeneration that we would like ported to CodeSmith. This will be pretty easy actually, as we have our own assemblies that will all run under CodeSmith. We use the MyMeta engine, which is now under the BSD license, and therefore can run under CodeSmith, as well. So, basically, we just need our templates converted, but the "core" of the templates will run as is. There is very little code that actually needs converting. Once you've done one of them, the rest will fall right into place. We have two sets of templates, one that creates our C# architecture, and one that creates our VB.NET architecture, but both sets of templates are written in C#.

There are two master templates (they have a simple UI), and eleven sub templates (no UI) per language (C# and VB.NET). If you, or your company, are interested in contracting out to convert these templates, please reply to this thread, or send an email to support @ entityspaces dot net. This is something we are ready to start on immediately.

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, 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 Thursday, January 31, 2008 8:24:02 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0]
 Saturday, January 19, 2008
kick it on DotNetKicks.com

This is only a preview of some of the big things planned for ES2008, this is not the roadmap. There are many items such as esDataSource improvements and various fixes that will be covered in the roadmap which will be published soon. ES2008 is going to roll out a little differently than have our past releases. Rather than rolling out releases at a rapid rate we are going to have two main releases for ES2008. This will result in greater productivity for the EntitySpaces team, and greater functionality for our customers, as the act of cutting a release itself burns a lot of cycles. We have dates in mind for these releases and they will published in the official roadmap. We have created a special place in our forums to talk about this preview and our upcoming roadmap when released, that is the place to make your wishes and concerns known. Let's take a very high level look at some of these key features.

New Code Generation Model

The EntitySpaces team has decided a new code generation model is needed for several reasons. One of the main reasons we have chosen a new model is to make it easier for customers to extend EntitySpaces. However, this new model will also make development much easier for the EntitySpaces team as well. The new EntitySpaces code generator will operate as an ASP.NET website hosted on your local machine or on a server within in your organization. However, even though we have chosen this approach we are not precluded from running these same templates under the CodeDOM model in the future as CodeSmith templates can use code behind pages. Here are some of the advantages of going to a pure ASP.NET website based code generation model.

  • No need to write our own code generator as ASP.NET itself can execute the templates naturally.
  • Developers are already familiar with this model.
  • Full Intellisense including Intellisense for our new esMetadataEngine.
  • Easy debugging, just step right into your templates while in Visual Studio (including Express versions).
  • Custom Objects can be formed that are different than what the database schema describes (true mapping).
  • Better template recording and playback capabilities.

Take a look at this high level diagram

image

We have received some very good input on our forums that had an impact on the feature set for ES2008, specifically, the concept of a template stack. The EntitySpaces Core templates will be required and generate the main classes. The EntitySpaces Optional templates are just that, optional, and will generate things such as our WCF proxy classes. The Custom User templates are templates written by our customers. These templates can be created, shared, even sold by 3rd party developers. We hope to have a place where customers can publish their templates, and our code generator will be able to display those for you and you can then optionally pull them down for inclusion into your template stack. The concept behind the template stack is that customers can both extend EntitySpaces with new functionality, and replace standard functionality that we provide in the optional templates, by swapping our templates out and theirs in. The idea is that users can really begin to customize EntitySpaces without the fear of losing edits to templates. These templates are written as .ASCX controls with code behind pages, and therefore, support for CodeSmith is one of our goals as well. Our templates will be written in C# as they are now, however EntitySpaces will continue to generate both C# and VB.NET architectures as always.

Our new esMetadataEngine will be different from the MyMeta engine in MyGeneration. It will not support JScript or VBScript and therefore will have no need for COM Interop, nor the need to be registered in the registry. In addition to reading the metadata from your database schema, our new esMetadataEngine will be able to serve up the metadata for custom designed objects, or mapped objects created by the customer that represent objects not specifically described in the database. Also, the esMetadataEngine will not be "hard-bound" to any 3rd party ADO.NET providers eliminating upgrade issues when vendors publish new providers. Of course, the esMetadataEngine will be based on the Factory pattern, and allow 3rd parties to add support to EntitySpaces for databases not supported by the EntitySpaces team.

Most likely the data behind our new ASP.NET code generation model will be saved in an SQL CE ".sdf" database. This will include things such as configuration data, connection strings, and template stack information.

EntitySpaces Class Streamlining

The generated EntitySpaces classes are going to be streamlined. A lot of the functionality that can be pushed down in the EntitySpaces "Core" will be, while many other things like the ".str" methods, and so on, are going to be made optional. Also, you will be able to have null constructors in your Custom classes. Basically, you will be able to generate bare bones EntitySpaces classes, and then, enhance them as you see fit using our new customizable template stack approach. Remember, 3rd parties can publish their templates for inclusion into your stack. There could be a few minor breaking changes as a result of this streamlining but we hope to keep them to a minimum, as we think we have one of the best APIs in the business.

DynamicQuery API Enhancements

We will be adding some powerful enhancements to further expand the power of the EntitySpaces DynamicQuery API.

We will be adding the ability to perform SubSelects at various places within the DynamicQuery API. A SubSelect will merely be another DynamicQuery inserted somewhere in the syntax. This is not unlike how our joins are performed. Let's take a look at a sample SubSelect statement.

ProductsQuery avg = new ProductsQuery("a");
avg.Select(avg.UnitPrice.Avg());

ProductsCollection p = new ProductsCollection("p");
p.Query.Select(p.Query.ProductName);

p.Query.Where(p.Query.UnitPrice > avg);  // <= SubSelect
p.Query.Load();

This will generate the following SQL:

SELECT p.ProductName
FROM Products p
WHERE p.UnitPrice>(SELECT AVG(a.UnitPrice) From Products a)

We will also be adding native language casting operations. There are many times when you need to coerce a data type from one type to another in SQL syntax, and currently, there is no way to express this in EntitySpaces. Below is an example of how this will work.

EmployeesCollection coll = new EmployeesCollection();
coll.Query.Select
(
    (coll.Query.LastName + " was hired on " +
        (string)coll.Query.HireDate).As("VirtualColumn")
);
coll.Query.Load();

In the sample above the (string) cast will result in the appropriate SQL being generated for the type of the database being accessed, for SQL this would be either the CAST or CONVERT function for instance to convert the SQL datetime to a varchar for concatenation.

EntitySpaces DataProvider Enhancements

Do not confuse these DataProviders with esMetadataEngine providers. EntitySpaces DataProviders are the providers used by EntitySpaces during runtime to access a database, not the providers used during code generation. These are the enhancements planned for ES2008.

  • IBM DB2 Express support.
  • VistaDB 3.3x support with VistaDB Stored Procedure Generation.
  • SQL CE Desktop Support.
  • 3rd Party Support will be enabled.

Summary

We know this is a lot to tackle for ES2008 and that is why we have chosen to roll this out in two releases rather than a bunch of smaller ones. We will be doing a lot of blogging on this, dive much further into various pieces, and hopefully elicit some feedback from our customer base. Also, we will publish a detailed roadmap for ES2008 in a few weeks.

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, 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 Saturday, January 19, 2008 6:45:09 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0]
 Wednesday, December 26, 2007
MyGeneration 1.3.0.3 Released - Code Generation, O/R Mapping, and Architectures

  • The Free Code Generator / OR Mapping Tool the competition doesn't want you to know about
  • The #1 .NET Development Tool on Download.com of all time.
  • A $199 value given away 100% free. No Adware or Spyware.
  • Supported Architectures - EntitySpaces,  EasyObjects.NET/EntLib,  Gentle.NET,  Opf3,  NHibernate,  Microsoft's DAAB,  DotNetNuke,  iBatis
  • Support for Twelve Different Database Systems.
  • Microsoft SQL,  Oracle,  IBM DB2,   PostgreSQL,  Microsoft Access,  FireBird,  Interbase,  VistaDB,  SQLite,  MySQL,  Advantage and Pervasive
  • Template Based Code Generator Supporting Four Template Languages - JScript, VBScript, C# and VB.NET
  • Ability to Create Your Own Embedded User Interface in your Templates
  • Online Template Library for Publishing and Downloading Templates



Update - 2008-01-03: There are specific EntitySpaces installers available for use with MyGeneration 1.3. They can be found on the Trial download page, or, for customers, under the latest Products -> Downloads page. Our recommendation is to install MyGeneration1.3 with the defaults. This will give you a side-by-side installation, with MyGeneration 1.3 in its own program folder. Make sure both versions of MyGeneration are closed before installing EntitySpaces. Again, we recommend taking the EntitySpaces for 1.3 installer defaults, for the best side-by-side experience.

posted on Wednesday, December 26, 2007 1:17:16 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0]
 Thursday, December 06, 2007

mono

 

EntitySpaces, LLC is offering $1,000 U.S. dollars to the first person or company to successfully create an EntitySpaces application that runs under Mono version 1.2.5.1 or higher and does so within the constraints of the rules outlined below. We will also make a follow up blog post announcing the winner which could help push traffic to your site if you are interested (and make you famous for at least 15 minutes).

The Rules

  1. The Application or Website must use Mono version 1.2.5.1 or higher.
  2. The Application must use EntitySpaces 2007 v1119 or higher.
  3. The Application must insert, update and delete data from the database using our standard EntitySpaces generated classes via the Save() method.
  4. The Application must use the EntitySpaces DynamicQuery API to perform a join and display the results.
  5. The Application must be created as an image in the "VMware Virtual Image" file format as found on http://www.mono-project.com/Downloads so that we can run it out of the box with no modifications.
  6. The image mentioned above in rule 5 must be submitted on a CD. 
  7. All submissions become the property of EntitySpaces, LLC and we reserve the right to make them available for marketing purposes.
  8. Your Submission must be received by January 31st, 2008 (only the first working solution submitted by January 31st, 2008 will receive the $1,000 U.S. dollars prize money).

If you are interested write to support@entityspaces.net and we can tell you where to forward your submission.

Most likely this application will use MySql or VistaDB as those are two of the databases we support that run under Mono (others we support might also run under Mono). Also, you might need to use the configless connection support for EntitySpaces configuration information. If you run into issues we are willing to work with you, however we are fairly confident that our assemblies are mono compliant. Of course, the nicer the UI the better, but the idea is to show off EntitySpaces running under Mono.


kick it on DotNetKicks.com 

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, 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 Thursday, December 06, 2007 6:15:10 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0]
 Saturday, December 01, 2007
image

 

Our mid-December maintenance release for v1119 offers a new class, the esEntityCollectionView. The esEntityCollectionView acts like the ADO.NET DataView class only for EntitySpaces Collections. This new class will allow you to have multiple views on the same collection each with a different sort and filter acting independently of other views. Also, the esEntityCollectionView class does not effect the Sort or the Filter properties on the collection itself. This means that you can use a collection as a cache and have various views on it displayed throughout your application. You can use the foreach syntax against the esEntityCollectionView class as well as the indexer (the foreach syntax is faster).

The esEntityCollectionView class uses the .NET Generic syntax mechanism. We really haven't needed to create many "generic" classes since we use code generation techniques to create our classes. It is too bad Microsoft didn't stick with the term "Template class" from the C++ world because this more clearly defines what the "generic" mechanism does. The compiler see's the "generic" class and literally generates a class (behind the scenes) for each type it encounters. So, you can think of a generic class as a template that is code generated at compile time, and since we code generate everything we haven't needed to use generics that often.

The new esEntityCollectionView is very useful, but it will not assume full power until EntitySpaces 2008 which will add full binding support to the esEntityCollectionView class. However, the LowLevelBind method is implemented which will let you bind directly to the underlying DataView.

Let's look a sample to get a feel for how to use this new class. In this case we create a collection and load all of the records, then we create two views on the collection and filter different ways and use the foreach syntax to enumerator over the collection. Notice both views operate independently of on another. If there was a sort or filter directly on the collection the views would be unaffected as well.

EmployeesCollection coll = new EmployeesCollection();
coll.LoadAll();

esEntityCollectionView<Employees> view1 = new esEntityCollectionView<Employees>(coll);
esEntityCollectionView<Employees> view2 = new esEntityCollectionView<Employees>(coll);

view1 .Filter = "LastName = 'Griffin'";
view2 .Filter = "LastName <> 'Griffin'";

foreach (Employees emp in view1 )
{
    string s = emp.LastName;
}

foreach (Employees emp in view2 )
{
    string s = emp.LastName;
}

// Show how to use the indexer ...
Employees e = view2 [10] as Employees;

We are sure that when EntitySpaces 2008 comes out you will find the esEntityCollectionView classes to be extremely useful. Not only will we build full data binding into it (as exists on the esEntityCollection) but thread synchronization too. The esEntityCollectionView class is perfect for use on cached collections. We are also implementing lots of tweaks/fixes as we gather them from the forums as well for our mid-December release which will include the esEntityCollectionView class.


kick it on DotNetKicks.com

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, 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 Saturday, December 01, 2007 11:03:56 AM (Eastern Standard Time, UTC-05:00)  #    Comments [1]
 Tuesday, November 20, 2007

Now that EntitySpaces 2007.1.1119.0 has been released we thought we would start a series of blog posts that highlights some of API enhancements. The most obvious place to begin is the Dynamic Query API as that is what many of our customers work in every day. We start off with some simple queries and work up to more complex queries.

Query - Simple select with where clause

Here is a simple query that brings back only the FirstName column for only those records that begin with the letter "M". Notice we use the % sign to indicate any characters after. You also use the % signs for all other supported databases. The EntitySpaces data providers will adjust accordingly for all other databases. Also, notice that we are using the built in query object on the collection itself. We recommend that you use this syntax always when there is no join involved.

EmployeesCollection coll = new EmployeesCollection ();
coll.Query.Select(coll.Query.FirstName);
coll.Query.Where(coll.Query.FirstName.Like("M%");
if(coll.Query.Load())
{
    // at least one record was loaded
}

The resulting SQL:

SELECT [FirstName]  FROM [Northwind].[dbo].[Employees] WHERE [FirstName] LIKE @FirstName1

Query - Arithmetic operators and complex where clause with AND/OR

This query shows off some of the natural language features of the EntitySpaces Dynamic Query API. Notice the use of the + operator to concatenate the FullName and LastName and providing the new derived column with an alias. Also notice the Where clause and it's use the | operator. You can use & for AND and | for OR and you can use ( ) for precedence.

EmployeesCollection coll = new EmployeesCollection ();
coll.Query.Select((coll.Query.LastName + "," + coll.Query.FirstName).As("FullName"));
coll.Query.Where(coll.Query.City == "Indianapolis" | coll.Query.Region == "Northeast");
if(coll.Query.Load())
{
    // at least one record was loaded
}

The resulting SQL:

SELECT ([LastName]+','+[FirstName]) AS 'FullName'  FROM [Northwind].[dbo].[Employees] WHERE ([City] = @City1 OR [Region] = @Region2)

Query - Aggregates with OrderBy and GroupBy

This query shows off some of the natural language features of the EntitySpaces Dynamic Query API. Notice the use of the + operator to concatenate the FullName and LastName and providing the new derived column with an alias. Also notice the Where clause and it's use the | operator. You can use & for AND and | for OR and you can use ( ) for precedence. Also, we had to use two calls to OrderBy because of the dynamic column created by the alias, however, you can pass multiple columns in like this -> coll.Query.OrderBy(coll.Query.ProductID.Descending, coll.Query.CategoryID.Ascending)

OrderDetailsCollection coll = new OrderDetailsCollection ();
coll.Query.Select
(
    coll.Query.ProductID,
    (coll.Query.Quantity * coll.Query.UnitPrice).Sum().As("TotalPrice")
);
coll.Query.GroupBy(coll.Query.ProductID);
coll.Query.OrderBy(coll.Query.ProductID.Ascending);
coll.Query.OrderBy("TotalPrice", esOrderByDirection.Ascending);
if(coll.Query.Load())
{
    // at least one record was loaded
}

The resulting SQL:

SELECT [ProductID],SUM(([Quantity]*[UnitPrice])) AS 'TotalPrice'  FROM [Northwind].[dbo].[Order Details] GROUP BY [ProductID] ORDER BY [ProductID] ASC,[TotalPrice] ASC

Query - Join Syntax

Notice the syntax here is a little different. When creating join based queries you do not use the embedded query object on the collection, you create your own and be sure to give it an alias. When you are not creating a join use the embedded query object as the examples above show. Also, in join scenarios you can select all from a particular column by passing the query into the select statement as follows -> Select(cust, order.OrderId) in this example the select will be Customer.*, Order.OrderId.

CustomerQuery cust = new CustomerQuery ("c");
OrderQuery order = new OrderQuery ("o");
OrderItemQuery item = new OrderItemQuery ("oi");

cust.Select(cust.CustomerName, (item.Quantity * item.UnitPrice).Sum().As("TotalSales"));
cust.InnerJoin(order).On(order.CustID == cust.CustomerID);
cust.InnerJoin(item).On(item.OrderID == order.OrderID);
cust.GroupBy(cust.CustomerName);
cust.OrderBy("TotalSales", esOrderByDirection.Descending);

CustomerCollection coll = new CustomerCollection ();
coll.Load(cust); // Notice we load the query via the Collection.Load() method

The resulting SQL:

SELECT c.[CustomerName],SUM(oi.[Quantity]) AS 'TotalSales'
FROM [ForeignKeyTest].[dbo].[Customer] c
JOIN [ForeignKeyTest].[dbo].[Order] o ON (o.[CustID] = c.[CustomerID])
JOIN [ForeignKeyTest].[dbo].[OrderItem] oi ON (oi.[OrderID] = o.[OrderID])
GROUP BY c.[CustomerName]
ORDER BY TotalSales DESC

Miscellaneous Tips and Tricks

  • You can trick a query object and force it to load from a database view instead of the table as follows

query.es.QuerySource = "SomeView";

  • Top, CountAll, Distinct, PageNumber, PageSize, LastQuery are all available in the coll.query.es data member.

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, 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 Tuesday, November 20, 2007 12:14:19 AM (Eastern Standard Time, UTC-05:00)  #    Comments [1]
 Sunday, November 18, 2007

I made a blog post a while ago in a thread entitled "Microsoft ruined data binding in ASP.NET 2.0 when they dropped component support from the design surface" and thought it worthy of a follow up.

ICustomTypeDescriptor

In order to allow strongly typed entities to tack on dynamic properties (extra columns brought back via a dynamic query) for data binding in ASP.NET data grid scenarios you must implement the ICustomTypeDescriptor interface. Since our latest release (v1119) supports joins it is now common to bring back extra columns for display purposes in EntitySpaces. Well, we implemented the ICustomTypeDescriptor interface on our esEntity class and it worked perfectly in ASP.NET, however, testing then showed it broke data binding in certain Windows.Forms scenarios. Why? There is a BUG in the Microsoft.NET Framework. It's not like bugs are not found in EntitySpaces of course, this is merely an explanation of how we have arrived to this point.

We have a few ways to work around the issue. One is to use our Collection.LowLevelBind() method and the other is adding properties to your entity (not very attractive). Our esDataSource control allows you to bring back extra columns and it binds just fine, there is a "LowLevelBind" method on the esDataSource for just this scenario. This only effects ASP.NET as Windows.Forms uses ITypedList which works like a champ (in hierarchical mode also).

HierarchicalDataSourceControl

The new HierarchicalDataSourceControl binding set of interfaces proved utterly incapable of displaying a hierarchical object model. We had it "kind of working" when we realized that this new binding model only supported a single parent/child relationship. This means it cannot display the EntitySpaces hierarchical object model. So, we withdrew the implementation of this feature. Scott Piegdon has a code sample on CodeProject, you can see his response to my "Ya, Butt" comment which validated my suspicions (nice article by the way).

Summary

Again, the new Microsoft ASP.NET data binding has proven to be flawed. It is next to impossible to support both ASP.NET and Windows.Forms binding with the same codebase due to a serious bug in the .NET Framework. Also, the HierarchicalDataSourceControl implementation suffers from a lack of foresight by its designers.

And finally (whining here) this all worked in the Microsoft .NET 1.x framework, see Part One as to how we got to where we are. The same ITypedList implementation worked for both ASP.NET and Windows.Forms. However, it was swapped out for some crazy DataSource model that is clearly geared for heavily reflected architectures. Well, EntitySpaces didn't take the bait. We are still 100% reflection free. We still run in "Medium Trust" and yes, we support the DataSource control but not the HierarchicalDataSourceControl. We have a plan to work around this issue entirely in a future release.

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, 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, November 18, 2007 9:24:47 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0]