Print Page | Close Window

Include keyword - Get All

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=2161
Printed Date: 14-Sep-2025 at 12:13pm


Topic: Include keyword - Get All
Posted By: Jakes
Subject: Include keyword - Get All
Date Posted: 15-Sep-2010 at 11:27pm
I have a query where I use the "Include" keyword to include a navigation property as so:

Address.Include("Cities");

This returns the one city for that address.

My question is, how do I return all the cities as part of a eager load and store it as a property on the Address object created by IdeaBlade. 

I want to use this property to databind a combobox itemssource in a datagrid for user selection.

Thanks in advance.



Replies:
Posted By: jcrada
Date Posted: 16-Sep-2010 at 12:29pm
I have used extension methods (http://msdn.microsoft.com/en-us/library/bb383977.aspx) for the entity manager then at the begining of my application I load the content of the citites table in asynchronous query, then when the user use the combobox the query is ready and my method return the items source getCities , in the worst case scenario the query will not be ready and the user must have to wait

public static class EntityManagerExtension
{
public static void LoadDataBaseObjects(this EntityManager manager) 
{
var citites =  manager.GetQuery<City>();
manager.ExecuteQueryAsync(citites);
                }

public static IEnumerable<City> getCities(this EntityManager manager) 
{
var citites =  manager.GetQuery<City>();
return manager.ExecuteQuery(citites);
}




Print Page | Close Window