Blogs

Gary's Blog

Linq Server Mode and Entity Framework 4.0 (coming in V2010 Vol 2)

     

We’ve supported Server Mode for our controls for some time now and it’s worked, out-of-the-box, for almost any Language-Integrated Query (LINQ) provider. For example the LinqServerModeSource can be used together with our WPF and Windows Forms grids, and the LinqServerModeDataSource can be used with our ASP.NET grid. So far so good. Unfortunately, the LINQ implementation in Entity Framework had some specifics preventing it from building effective dynamic queries for those types that are not known at compile time.  Worse, there were Entity Framework specifics which required workarounds which did not work in a medium trust environment.

Well it’s time to fix all that. As of the forthcoming V2010 Vol 2 release, we’ll be providing complete support for Entity Framework in our Data Library. Of course, when I say Entity Framework, I mean EF 4.0 and above – but then you knew that, ‘cos nobody would take a dependency on EF before the 4.0 release, right? There is one limitation though, the maximum number of total or group summaries allowed is 14, but I’m sure you can live with that. Smile

Okay, enough chit chat, let’s have an example. First thing to do is to create a storage model and mapping information. So, add the ADO.NET Entity Data Model item template and configure it using the Entity Data Model Wizard:

LoadItem

Select “Generate from Database”:

LoadItem(1)

Select the Northwind database:

LoadItem(2)

Select the “Products” table:

LoadItem(3)

And we’re done!

LoadItem(4)

Next, let’s add a grid to our window:

<Window x:Class="DXGrid_EF4_ServerMode.MainWindow" 
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
        Title="MainWindow" 
        Height="350" 
        Width="525" 
        xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <dxg:GridControl Name="grid" AutoPopulateColumns="True">
            <dxg:GridControl.View>
    <dxg:TableView ShowTotalSummary="True" />
            </dxg:GridControl.View>
        </dxg:GridControl>
    </Grid>
</Window>

And then bind to the data:

public partial class MainWindow : Window {
    public MainWindow() {
        InitializeComponent();
        NorthwindEntities dataContext = new NorthwindEntities();
        grid.DataSource = new LinqServerModeSource() {
            ElementType = typeof(Product),
            KeyExpression = "ProductID",
            QueryableSource = dataContext.Products
        };
    }
}

For more information oh how Server Mode works, albeit with an OData twist, check out this post.

Oh, and the news just keeps getting better and better. Not only is this technology coming in V2010.2, but there was a beta version released in V2010.1.6, so you can start playing with it now!

Published Aug 23 2010, 06:59 PM by Gary Short (DevExpress)
Filed under: ,
Technorati tags: v2010.2, XPO
Bookmark and Share

Comments

 

Stefan Heim said:

Hi Gary,

nice, but I'm not sure what this has to do with XPO?! Do you have some real news regarding XPO and 2010.2?

Thank, Stefan

August 23, 2010 2:30 PM
 

Brad Raulston said:

I was kind of thinking the same thing as Stefan.

Brad

August 23, 2010 2:56 PM
 

Gary Short (DevExpress) said:

Hi guys, yes you are right, it's just force of habit on my part, putting XPO in front of all data-centric posts. Thanks for the catch, I've changed it now. :-)

August 23, 2010 3:07 PM
 

Martin Praxmarer [DX-Squad] said:

So you should give us the real news about XPO now Gary ;)

August 23, 2010 3:15 PM
 

Julian Bucknall (DevExpress) said:

Gary: "force of habit on my part, putting XPO in front". Damn, you just made my day. Would have been even more awesome on April 1...

Cheers, Julian

August 23, 2010 6:18 PM
 

Michael Kaldeck said:

Great !

In practice for me it's usability will depend if it is also bindable to SP's that have been mapped into the model. So one can have filtered data. Or will there be another way to limit data via criteria at runtime ?

Michael

August 24, 2010 2:04 AM
 

Crono said:

Right now, AFAIK. a grid using a Linq source in server mode is readonly.

So... when you say "complete support" for EF, does it means that data will be editable as well?

November 3, 2010 2:22 PM
More from DevExpress
Live Chat
Have a pre-sales question?
Need assistance with your evaluation?
We are here to help.
Chat is one of the many ways you can contact members of the DevExpress Team. We are available Monday-Friday between 8:30am and 5:00pm Pacific Time.
If you need additional product information, require pre-sales assistance, or want help with your order, write to us at info@devexpress.com or call us at
+1 (818) 844-3383.