Using the return type IQueryable<TABLE_1>
I am new to silverlight, many posts indicate using observablecollection is the best.
Domainservice1 returns IQUERYABLE type.
How to work with this return type in silverlight side?
How to convert/cast the data returned to observable collection?
Th开发者_JAVA技巧e DomainServices1.cs
public IQueryable<TABLE_1> GetTABLE_1()
{
return this.ObjectContext.TABLE_1;
}
*The HOME.XAML.CS***
public Home()
{
InitializeComponent();
this.Title = ApplicationStrings.HomePageTitle;
Web.DomainService1 dservice = new Web.DomainService1();
EntityQuery<Web.TABLE_1> query=new EntityQuery<Web.TABLE_1>();
query = dservice.GetTABLE_1Query();
//Convert result to ObservableCollection
//bind the grid ITEM SOURCE
}
The IQueryable does not return results until you enumerate the collection. so for instance if you wanted to limit the results of that dservice.getTable_1Query with a .where() you could...
to get the object into an observable collection you .tolist the query like this
observablecollection<Table1> t=new observablecollection<Table1>(query.ToList());
I actually think there is a little more that you have to do(a loadoperation is how I do mine) I am in the learning stages of the linq dynamic, but from other applications that i have had to convert returned results to an observable collection; that is how i did it. I actually wrote an exension so that I could .ToObservableCollection
精彩评论