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 system architect and principal in PH&V Information Services. PH&V provides full-stack consulting from UX design through object modeling to database design. Peter tweets about his VSM columns with the hashtag #vogelarticles. His blog posts on user experience design can be found at http://blog.learningtree.com/tag/ui/.

comments powered by Disqus

Featured

  • AI for GitHub Collaboration? Maybe Not So Much

    No doubt GitHub Copilot has been a boon for developers, but AI might not be the best tool for collaboration, according to developers weighing in on a recent social media post from the GitHub team.

  • Visual Studio 2022 Getting VS Code 'Command Palette' Equivalent

    As any Visual Studio Code user knows, the editor's command palette is a powerful tool for getting things done quickly, without having to navigate through menus and dialogs. Now, we learn how an equivalent is coming for Microsoft's flagship Visual Studio IDE, invoked by the same familiar Ctrl+Shift+P keyboard shortcut.

  • .NET 9 Preview 3: 'I've Been Waiting 9 Years for This API!'

    Microsoft's third preview of .NET 9 sees a lot of minor tweaks and fixes with no earth-shaking new functionality, but little things can be important to individual developers.

  • Data Anomaly Detection Using a Neural Autoencoder with C#

    Dr. James McCaffrey of Microsoft Research tackles the process of examining a set of source data to find data items that are different in some way from the majority of the source items.

  • What's New for Python, Java in Visual Studio Code

    Microsoft announced March 2024 updates to its Python and Java extensions for Visual Studio Code, the open source-based, cross-platform code editor that has repeatedly been named the No. 1 tool in major development surveys.

Subscribe on YouTube