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