EntityQuery<DataSetData> query3 = ds2.getsampleresult_2Query();
LoadOperation<DataSetData> lo = ds2.Load(query3, LoadBehavior.RefreshCurrent, true);
lo.Completed += new EventHandler(lo_Completed_2);
And my in callback function
LoadOperation<DataSetData> vals = sender as LoadOperation<DataSetData>;
if (!vals.HasError)
{
DataSetData data = null;
data = vals.Entities.FirstOrDefault();
IEnumerable list = DynamicDataBuilder.GetDataList(data);
And then in GetDataList function
public static IEnumerable GetDataList(DataSetData data)
{
if (data.Tables.Count() == 0)
return null;
DataTableInfo tableInfo = data.Tables.FirstOrDefault();
here when I do (tableInfo.Columns).Count = 15 , which should be 6 , and it is carrying the 9 columns of previous datasetdata query.
I'm sure it is DomainContext which caches the old data, that's why I asked if the loadbehavior is set to RefreshCurrent. I'll try to test it myself to see what is going on.
Sally Xu
Software Engineer
Aprimo, Inc
Please remember to mark the replies as answers if they answered your question
yeh but I am using LoadBehavior.RefreshCurrent , so how come Domainservice is still maintaining the result in cache ??? if it is then it can be very problematic in other scenraios as well !!!
OK, I test with my solution and I don't have the problem you are having.
What is you Service query function look like? Make sure to give DataSet a different Name if you query different table.
try this:
public DataSetData GetSampleData( string Name, ...) // You can pass Name to the query function.
{
//Return your DataSetData; //Set the DataSet with the Name
}
Sally Xu
Software Engineer
Aprimo, Inc
Please remember to mark the replies as answers if they answered your question
I think I have found the solution.
If you set your domainservice EntityConatiner.Clear and load with loadbehaviour.RefreshCurrent , then it loads only the correct columns.
ds2.EntityContainer.Clear();
LoadOperation<DataSetData> lo = ds2.Load(query3,LoadBehavior.RefreshCurrent, true);
Any Idea how can I implement Paging with this dataset ? I can attach DataPager, but it loads all the records from DB and show the rows mentioned in it PageSize.
But If I want to use DomainDataSource LoadSize kind of thing , how can I implement it using DataSetData ?
Thank you so much for this, sladapter. Really saved my day.
I was able to convert this to VB.NET after som struggle, and everything seems to be working except for the GetDataSetDataCompletedEventArgs ServerError parameter which is not working correctly for some reason. I did not take the time to investigate the problem,
probably just a quick adjustment.
maverick_SL
Member
16 Points
12 Posts
Re: Re: How to Display DataSet in Silverlight DataGrid
Jun 17, 2011 07:18 PM | LINK
I am calling my domainservice method like this
EntityQuery<DataSetData> query3 = ds2.getsampleresult_2Query(); LoadOperation<DataSetData> lo = ds2.Load(query3, LoadBehavior.RefreshCurrent, true); lo.Completed += new EventHandler(lo_Completed_2);And my in callback function
LoadOperation<DataSetData> vals = sender as LoadOperation<DataSetData>; if (!vals.HasError) { DataSetData data = null; data = vals.Entities.FirstOrDefault(); IEnumerable list = DynamicDataBuilder.GetDataList(data);And then in GetDataList function
public static IEnumerable GetDataList(DataSetData data) { if (data.Tables.Count() == 0) return null; DataTableInfo tableInfo = data.Tables.FirstOrDefault();here when I do (tableInfo.Columns).Count = 15 , which should be 6 , and it is carrying the 9 columns of previous datasetdata query.
Which is very weird !!!
maverick_SL
Member
16 Points
12 Posts
Re: Re: How to Display DataSet in Silverlight DataGrid
Jun 18, 2011 05:45 PM | LINK
I have found an interesting thing , if I 'new' my domainservice on every call , then it works fine . Like if I change my calling method like this
sladapter
All-Star
43609 Points
7910 Posts
Re: Re: How to Display DataSet in Silverlight DataGrid
Jun 18, 2011 06:00 PM | LINK
I'm sure it is DomainContext which caches the old data, that's why I asked if the loadbehavior is set to RefreshCurrent. I'll try to test it myself to see what is going on.
Software Engineer
Aprimo, Inc
Please remember to mark the replies as answers if they answered your question
maverick_SL
Member
16 Points
12 Posts
Re: Re: How to Display DataSet in Silverlight DataGrid
Jun 18, 2011 07:04 PM | LINK
yeh but I am using LoadBehavior.RefreshCurrent , so how come Domainservice is still maintaining the result in cache ??? if it is then it can be very problematic in other scenraios as well !!!
sladapter
All-Star
43609 Points
7910 Posts
Re: Re: How to Display DataSet in Silverlight DataGrid
Jun 19, 2011 12:08 AM | LINK
OK, I test with my solution and I don't have the problem you are having.
What is you Service query function look like? Make sure to give DataSet a different Name if you query different table.
try this:
public DataSetData GetSampleData( string Name, ...) // You can pass Name to the query function.
{
//Return your DataSetData; //Set the DataSet with the Name
}
Software Engineer
Aprimo, Inc
Please remember to mark the replies as answers if they answered your question
maverick_SL
Member
16 Points
12 Posts
Re: Re: How to Display DataSet in Silverlight DataGrid
Jun 19, 2011 06:55 AM | LINK
If I rename my DataSetData like this
DataSetData dsd = new DataSetData();
dsd.DataSetName = "dsd_" + tbl;
Just before return , I can see that dsd.Tables.Count = 1 , and when I recive this datasetdata on clientside like this
DataSetData data = null;
data = vals.Entities.FirstOrDefault();
then my data.Tables.Count = 0. So nothing binds.
And If I just leave dsd.DataSetName = null , it returns the table on client side but with my original problem.
Can you please share your RIA Services Solution ? May be while collecting the code from various posts on this thread , I have missed something
Thanks.
maverick_SL
Member
16 Points
12 Posts
Re: Re: How to Display DataSet in Silverlight DataGrid
Jun 20, 2011 09:20 AM | LINK
I think I have found the solution.
If you set your domainservice EntityConatiner.Clear and load with loadbehaviour.RefreshCurrent , then it loads only the correct columns.
ds2.EntityContainer.Clear();
LoadOperation<DataSetData> lo = ds2.Load(query3,LoadBehavior.RefreshCurrent, true);
Any Idea how can I implement Paging with this dataset ? I can attach DataPager, but it loads all the records from DB and show the rows mentioned in it PageSize.
But If I want to use DomainDataSource LoadSize kind of thing , how can I implement it using DataSetData ?
Thanks.
eirikh
Member
2 Points
1 Post
Re: How to Display DataSet in Silverlight DataGrid
Aug 29, 2011 07:20 AM | LINK
Thank you so much for this, sladapter. Really saved my day.
I was able to convert this to VB.NET after som struggle, and everything seems to be working except for the GetDataSetDataCompletedEventArgs ServerError parameter which is not working correctly for some reason. I did not take the time to investigate the problem, probably just a quick adjustment.
So anyone looking for a VB.NET version of this can take a look at DataSetInDataGrid_VB_20110829.zip
I did not convert the code in sladapter's Page.xaml.cs as I used this in a slightly different way.
VasuPatel
Member
2 Points
5 Posts
Re: How to Display DataSet in Silverlight DataGrid
Apr 13, 2012 11:04 AM | LINK
Hi
Thank you.
i have implement your code but how i get all object on SelectionChanged of datagrid .
theGrid.SelectedItems it give IList object,so how can i get all object so that i can compare or check value of all row based on condition.
demmith2
Member
2 Points
1 Post
Re: How to Display DataSet in Silverlight DataGrid
May 17, 2012 05:22 PM | LINK
The code you write about came from http://blog.bodurov.com/How-to-Bind-Silverlight-DataGrid-From-IEnumerable-of-IDictionary/