Developer's Toolkit

ComponentOne Studio for Entity Framework: Intelligent Data Management

SEF provides an additional layer of data management to your forms to improve your application's data-access efficiency.

Improving an application's response time often comes down to finding clever ways to either manage large amounts of data or to reduce trips to the database. You can write that code yourself or you can pick up the ComponentOne Studio for Entity Framework (SEF) and let SEF do it for you, either on the client or on the server.

The easiest way to use SEF in a project that uses Entity Framework (EF) is to drop the C1DataSource control on a Windows Forms, Windows Presentation Foundation or Silverlight form. After that, you just need to set the control to your EF model and one of your model's entities to have the control act like any ordinary data source.

What makes the C1DataSource different from other data sources is that it doesn't tie directly to your EF model. Instead, a C1DataSource control accesses EF through one or more EntityViewSources, each of which can be tied to a different EntitySet. The C1DataSource automatically creates and manages a sophisticated client-side cache of all your EF objects, allowing the C1DataSource to manage objects that are shared among parts of a form. For instance, a form that retrieves all the Orders for a Customer on one tab and displays Order (or Order_Line) detail on another tab requires only a single C1DataSource, which will automatically share EF entities between the tabs.

When forms retrieve large amounts of data, the number of entities created by Entity Framework will also get large, swamping memory and giving you sluggish performance. When the C1DataSource is put in Virtual mode and tied to a single control, the C1DataSource retrieves rows from EF on an "as needed" basis, creating the related objects when the entities are being displayed and disposing of them when they're no long required. The C1DataSource automatically retains any objects that have had changes made to them until you decide to save those changes. (Calling the SaveChanges method on the client-side cache of the C1DataSource saves changes on all the EntityViewSources managed by the data source.) Virtual mode isn't useful, however, with controls that automatically process all the rows specified -- for example, the Silverlight DataGrid.

[Click on image for larger view.] Figure 1. The single line of XAML that adds the C1DataSource allows the DataGrid to handle millions of rows quickly.

Rather than write code to issue new queries (and make additional trips to the database), SEF lets you declaratively set filters to specify the data to retrieve. SEF will automatically attempt to satisfy those queries from the local cache and only retrieve data when it's not available in the cache. SEF also integrates ComponentOne LiveLinq to index the results in the local cache and allow you to issue "AsLive" LINQ queries that automatically stay current with the database.

Finally, SEF isn't tied to the C1DataSource -- you can access the underlying objects from code to create and manage your own cache of entities at the server. You can issue your own LINQ queries against your entity cache and define your own LiveLinq indexes.

The documentation is excellent, providing task-based introductions to the technology along with details on how to exploit the tool.

If you're building applications with forms that display a single EntitySet with good performance, then you don't need SEF. However, if you're fighting with sluggish performance or complex code in an application that marshals multiple EntitySets, fighting with forms that display data in multiple locations, or wrestling with a large number of rows in a grid, then SEF could be the solution you're looking for.

More Info

Web: componentone.com
Phone: 800-858-2739
Price: $395.00 (upgrades: $295)
Quick Facts: A data management layer for form-based applications that improves data access
Pros: Improves data-processing efficiency in .NET applications by leveraging a client-side cache; integrates ComponentOne LiveLinq
Cons: No control-based support for ASP.NET or ASP.NET MVC

About the Author

Peter Vogel is a principal in PH&V Information Services, specializing in Web development with expertise in SOA, client-side development, and user interface design. Peter tweets about his VSM columns with the hashtag #vogelarticles. His most recent book ("rtfm*") is on writing effective user manuals, and his blog on language and technical writing can be found at rtfmphvis.blogspot.com.

comments powered by Disqus

Reader Comments:

Add Your Comments Now:

Your Name:(optional)
Your Email:(optional)
Your Location:(optional)
Comment:
Please type the letters/numbers you see above

.NET Insight

Sign up for our newsletter.

I agree to this site's Privacy Policy.