Archive for February 2009
Behind The Scene: Astoria Data Source Control
Hi
Probably some of you are confused with the declarative configuration that you need to set up when you want to use Astoria Data Source control from Intersoft DataSource™. In this post I’ll try to elaborate the things one by one so hopefully its easier to understand how the Astoria Data Source control works.
First of all let me show you one way to select data from Astoria Data Service manually. I assumed you already know how to establish Astoria Data Service, or you can always learn it from my earlier post, or from MSDN references.
As you can see we need to do lots of things, creating the service proxy / object, create the query, call the asynchronous call. Then attached the asynchronous call back where we can grab the data then apply it to our UI control. Furthermore we’re going to need similar process for Create, Update and Delete operation which might take some time to manage it properly.
Here where Astoria Data Source tries to help, it tries to simply the CRUD operation to ADO.NET Data Service. Please see the note i put in the picture above. Those are the information we need for Astoria Data Source declarative configuration.
The Reference Namespace was defined when you set the service reference in your silverlight project.
The Service TypeName is your ADO.NET Data Service’s Object Context where you define in your MyNorthwind.svc.cs file.
The Service Host is basically the host that contains the ADO.NET Data Service file, while the Service Target is the actual ADO.NET Data Service file. Later when you deploy the project, you need to adjust the Service Host accordingly to where you host your application.
The Data Object TypeName is object type that available in your ADO.NET Data Service, in this case i used Northwind Database therefore I’ll have Customers, Products, Employees, etc as my Data Object TypeName.
Here is what its how the declarative configuration looks like:
Given this info, its enough for us to help you perform CRUD operation in more elegant way. One thing you should note that you can also specified the configuration individually per AstoriaDataService, something like:
In this configuration, the AstoriaDataService[Customers] will look to http://localhost:52026/MyNorthwind1.svc instead of http://localhost:52025/MyNorthwind.svc. So if you have multiple services you don’t need to create additional data source control and configure other integrated features, you just need to set this individual settings to each data service and you’re set.
To do Data Binding with this Astoria Data Source: Data Binding to Silverlight Data Bound Control using Intersoft Data Source(tm)
To do CRUD operation using Astoria Data Source: Performing CRUD to Silverlight Data Grid using Intersoft Data Source ™
To do Child Data Retrieval using Astoria Data Source: Performing Child Data Retrieval using Intersoft DataSource™
Next I want to show you event handlers that Astoria Data Source has, and what you can do at each event.
- Object Creating Event
This is called when Service Object is going to be created.
–> at this point
proxy = new MySilverlightApplication.MyServiceReference.NorthwindEntities(new Uri(“http://localhost:52025/MyNorthwind.svc”));
- Object Created Event
This event is called when Service Object has been created.
proxy = new MySilverlightApplication.MyServiceReference.NorthwindEntities(new Uri(“http://localhost:52025/MyNorthwind.svc”));
–> at this pointYou can grab the Service Object from the event argument, and probably change some property inside it if necessary.
- Object Disposing Event
This event is called when the Service Object is going to be disposed.
Again we passed the Service Object here, just in case you need to do additional clear up before the Service Object is disposed. - Selecting Event
This event is called before we perform asynchronous call to perform data selection. You can add / change additional select argument or supply your own query like what i did in Performing Child Data Retrieval using Intersoft DataSource™ .
–> at this point
serviceQuery.BeginExecute(new AsyncCallback(GetCustomersCompleted), serviceQuery);
- Selected Event
This event is called when the asynchronous call is finished, and the data has been retrieved.private void
GetCustomersCompleted(IAsyncResult result)
{–> at this point
In this event you can grab the data using args.ReturnValue, and probably perform additional sub query as necessary before returning it to the UI. You can also check for Exception if the ADO.NET Data Service returns an exception from args.Exception.
- Inserting Event
This event is called before the inserting process is executed, you can grab the actual object that going to be inserted at e.NewObjectInstance where you might want to change things if necessary. - Inserted Event
This event is called after the inserting process is executed, you can grab the Exception as usual if the ADO.NET Data Service returns an exception from args.Exception. You can also grab the return object from ADO.NET Data Service using args.ReturnValue. - Updating Event
This event is called before the updating process is executed, you can grab the actual object that going to be updated at e.NewObjectInstance where you might want to change things if necessary. If you supply the original object (for Concurrency checking purpose) you can grab the object using e.OldObjectInstance. - Updated Event
This event is called after the updating process is executed, you can grab the Exception as usual if the ADO.NET Data Service returns an exception from args.Exception. You can also grab the return object from ADO.NET Data Service using args.ReturnValue. - Deleting Event
This event is called before the deleting process is executed, you can grab the actual object that going to be deleted at e.OldObjectInstancewhere you might want to change things if necessary. - Deleted Event
This event is called after the deleting process is executed, you can grab the Exception as usual if the ADO.NET Data Service returns an exception from args.Exception. You can also grab the return object from ADO.NET Data Service using args.ReturnValue.
In all of this event you have e.ServiceName to distinguish operation between AstoriaDataService, so you can target the action accordingly per service.
Thats all for now.
Hope this clear things about how Astoria Data Source control works.
Regards
Andry
Virtual Scroll™ implementation in Intersoft Presenter™
Hi,
In the past week I’ve been posting about several concept that we have around February 2009 CTP which includes Intersoft Presenter™ and Intersoft DataSource™. Today I want to highlight one of the features that we focus on in our early development.
When creating a control that shows data we must think of scalability and performance. Lets say a user want to show 10.000 records or more, if we render all of these records as Silverlight element, you can imagine how many resources it will take from our CPU, then what if we scroll them all together?
Considering this kind of condition, we try several ways to improve it and we come out with this Virtual Scroll™ concept. We’re adapting the concept we used in Intersoft CoverFlow’s Virtual Flow™ to this Virtual Scroll™ and enhance the necessary things accordingly.
Now you might wonder what’s the benefit of this Virtual Scroll™ concept.
- Better scalability and better performance.
- Better memory consumption
- Better user experience
To show the power of Virtual Scroll™, i’ve created a comparison sample that you can test it directly.
The sample contains a Wrap Panel from Silverlight Toolkit that was put inside a Scroll Viewer so we can scroll the content, and also Icon Presenter from Intersoft Presenter™.
Then we’re going to give both of control with 10.000 records of data.
You can see the video of this demo here.
Regards
Andry
Performing Child Data Retrieval using Intersoft DataSource™
Hello,
I promised several of our respondents to have a sample that demonstrate capability to retrieve child collection from parent object using Intersoft Data Source™. So I’ll try to elaborate it in this post in detail with step by step approach.
- Sign up and download the Intersoft Data Source™ CTP release from here.
- Follow the steps to create Astoria (ADO.NET Data Service) connection and set the service reference to your Silverlight Application Project. (Here is the link)
- Don’t forget to add reference to ISNet.Silverlight, ISNet.SIlverlight.DataSource and System.Windows.Controls.Data.
- Lets start by creating the UI first.
In this sample I’m going to use three data grids to show Customers – Orders – Orders Details relationship. So the first Grid will show the list of Customers, the second Grid will show the Orders from selected customer in the Customers Data Grid, and the third Grid will show the Order Details from selected order in Orders Data Grid.
- Insert the Astoria Data Source and configure its settings.
- Since I want my grid to retrieve the child data when ever i select a row in the grid, I’m going to hook the SelectionChanged event in Customers Grid and Orders Grid
- Next we need to attached Selecting and Selected Event Handler in Astoria Data Source, so that we can control the data retrieval process later on.
- Everything is set, and now lets go to the code behind.
- First of all we want the Application to load the data directly when application is loaded, therefore we need to call AstoriaDataSource1.Select(“Customers”) when the application is ready.
- Remember that we attached SelectionChanged event for Customers Grid and Orders Grid? Lets put some action into it.
So we will retrieve Orders when an item in Customers Grid is selected, and we will retrieve Orders Details when an item in Orders Grid is selected.
- Now is the important part. When we call AstoriaDataSource1.Select(“Orders”) in CustomersGrid_SelectionChanged, we want it only to retrieve the Orders from selected item (Customer with specific CustomerID). So how can we handle this?
Currently you need to handle it at Astoria Data Source’s Selecting Event Handler as follows.
When you call AstoriaDataSource1.Select(“Orders”), it will asked the AstoriaDataSource to perform data retrieval process. You can interupt the process at two points which are at the beginning (Selecting) and at the ending (Selected). Since we want the AstoriaDataSource to select only Orders of current selected Customer, we need to provide advance query during Selecting event.
Customers customer = CustomersGrid.SelectedItem as Customers;
var query = from c in context.CreateQuery<Customers>(“Customers”).Expand(“Orders”)
where c.CustomerID == customer.CustomerID
select c;DataServiceQuery<Customers> serviceQuery = query as DataServiceQuery<Customers>;
e.DataServiceQuery = serviceQuery;
By providing e.DataServiceQuery with an advanced query like this, the Astoria Data Source will compile it and send it to Astoria Data Service.
- Lastly what you need to do is to handle the action when the data is retrieved at the Selected Event.
Since Astoria sends the data back as collection of EntityDescriptor, we need to do additional Linq query to get the object collection correctly.
In the query i also put additional checking c.Entity.GetType() == typeof(Orders) is to filter out parent data when we’re doing child data retrieval.
- And we’re done. Run your application and you’ll get something like this.
Regards
Andry
Extending Intersoft Presenter™ through IDataPresenter
In the post when I introduce Intersoft Presenter™ for the first time, i mentioned that we realized that there are so many innovative ways that user can come out to visualize a data, and with silverlight technology the possibilities are even larger for future sleek data visualization.
Understanding this possibilities we carefully design the Intersoft Presenter™ so that you can integrate your own sleek data visualization into Intersoft Presenter™. In this blog i want to share the extensibility concept that Intersoft Presenter™ provides, which can be done in five easy steps.
- Create the user control that have data visualization control.
For this demo, i used Silverlight Toolkit’s Charting control which you can get from here
- Implements the IDataPresenter interface to the user control.

The important of this step is that you need to handle the Refresh Data Presenter method. Which basically feeding up you Data Visualization control with the data source passed by IDataPresenter mechanism.
- Add the new “Presenter” or the user control you just created into a ready Data Presenter Manager. Follow these steps to create a Data Presenter Manager with codeless data binding.
- Configure the necessary settings that came along with the IDataPresenter.
You can configure the Presenter Icon Dimension, Icon Space, Caption and so on, feel free to play with each settings to get different result
- Run the application and select the new “Presenter” you just added.
Now the nicest thing about this is that because everything is shared, everything is synchronized. Whenever you sort or filter the data it will also reflect to your newly added presenter as well as the other integrated presenter.
Regards
Andry
ansoesil.wordpress.com has changed its appearance.
For better readability, i decided to pick a simplier theme with larger space. Hopefully this new appearance is more convenient to all of you.
Regards
Andry
Intersoft Presenter™ Codeless Data Binding
Hi again
In the CTP there are lots of things that we want to introduce, in this post I’ll highlight the codeless data binding concept of Intersoft Presenter™.
The codeless data binding concept allows the Intersoft Presenter™ to perform data transaction such as Filtering, Sorting (available in CTP) , Paging, Data Editing, etc (available in later release) from / to data base with very less-code even code-less. So this will save developer lots of time to come out with functional Data Visualization with some basic data manipulation.
I’m going to give some demonstration here, how to create a data visualization application using Intersoft Presenter™. Follows are the steps.
- Sign up and download the Intersoft Presenter™ and Intersoft Data Source™ CTP release from here.
- Follow the steps to create Astoria (ADO.NET Data Service) connection and set the service reference to your Silverlight Application Project. (Here is the link)
- Don’t forget to add reference to ISNet.Silverlight, ISNet.SIlverlight.DataSource, ISNet.Silverlight.Presenter.
- Lets start to create a data visualization application with Intersoft Presenter.
- First I’m going to insert the Astoria Data Source control to connect to the Astoria Data Service (ADO.NET Data Service) we just created.
- Next we create the Data Presenter Manager that contains all the Presenter available in CTP (Icon Presenter, List Presenter and Grid Presenter)
- To do the codeless data binding, basically you just need the DataSourceID and DataMember.
- In this sample i configure the DataSourceID and DataMember at the Data Presenter Manager level, by doing this all the Presenters that attached to it will look up to the same DataSource Control and DataMember. (You can change the configuration individually per Presenter)
- Overall you will only have this in your xaml page
- And this is what you have in xaml.cs page
- Run the application, and try do filtering and sorting. You’ll see that the filtering and sorting was handled by Astoria Data Source which requesting the data from Astoria (ADO.NET Data Service), without any code at all.
Notes:
Even though everything is handled automatically, you can still give personal touch to it. We will provide several points where you can interrupt the process and add you custom logic. For example for the data retrieval process we have Selecting event and Selected event handler at Data Source level. You can add additional info during selecting event, or manipulate the data retrieved during selected event using LINQ or any other approach.
If you have more advanced scenario that you want to achieve, just let us know. We will try to accommodate that, after all these tools are created to help the development process not the other way around.
Regards
Andry
Performing CRUD to Silverlight Data Grid using Intersoft Data Source ™
Hi
In the last blog, i demonstrated how to do databinding to Silverlight Data Bound controls such as Data Grid, List Box and Combo Box. Continuing from that in this post I’m going to show to perform the CRUD operations which using the two ways data binding concept from silverlight.
Follows are step by steps to perform CRUD to Astoria Data Service through Intersoft Data Source control.
- Sign up and download the Intersoft Data Source™ CTP release from here.
- Follow the steps to create Astoria (ADO.NET Data Service) connection and set the service reference to your Silverlight Application Project. (Here is the link)
- Don’t forget to add reference to ISNet.Silverlight, ISNet.SIlverlight.DataSource and System.Windows.Controls.Data.
- Lets start to create the simple UI for this demo.
- First I’m going to insert the data grid and the Astoria Data Source
- After that I’m going to create several controller buttons to help the CRUD actions. These basically just buttons (Insert, Update button to launch a form, Delete button to delete the selected row, Reload button to reload the data)
- Next, I’m creating the form which contains CustomerID, ContactName and CompanyName with two ways data binding, so i just need to pass the DataContext from Grid to this Form.
- In Microsoft Expression Blend, you’ll get something like this
- After we finished with the UI, I’ll show you how to do the CRUD from the code behind.
- First of all we gonna perform the data retrieval (Read operation)
- Second, I’m inserting the event handler to the Controller.
Insert Button, will show up a form that supplied with the data context. Same goes for Update Button.
For the Delete Button, it will perform the data deletion to the current selected item in the grid (Delete operation).
- Lastly is handling the Create and Update Operation from the Form Event Handler.
- After that you can run the project, and try to insert new record, update and delete it. Note that you can’t delete the existing customers because it has relationship to another table.
Regards
Andry
Data Binding to Silverlight Data Bound Control using Intersoft Data Source(tm)
Hi
Several of our respondents interested to see how our data source control can perform data binding + CRUD operation to standard Silverlight Controls such as Data Grid, List Box and Combo Box.
So in this post, i’ll demonstrate it a bit. Follows are step by steps to perform data binding to Astoria Data Service through Intersoft Data Source control.
- Sign up and download the Intersoft Data Source™ CTP release from here.
- Create new project and use the Silverlight Application Template.
- Accept the notification to create a new ASP.NET Web Project to the solution to host Silverlight.
- Create new Astoria Data Model (ADO.NET Entity Data Model) in the ASP.NET Web Projects so we can consume it directly.
- Select Generate the model from database.
- Choose the database (I picked northwind.mdf, which also available in the downloaded sample).
- Check any Tables that you want to includes in the service.
- Next you need to create the Astoria Data Service (ADO.NET Data Service).
- Configure the configuration as below.
- Now we have the Astoria Data Service ready, to test it just view in browser the NorthindDataService.svc
- Now we go to the Silverlight Application Project and add reference to ISNet.Silverlight, ISNet.SIlverlight.DataSource and System.Windows.Controls.Data, and also don’t forget to add service reference to the Astoria Data Service you just created.
- Now in the Silverlight Project we create a new page (or you can use the page.xaml).
- Insert Astoria Data Source control, then insert several standard Silverlight Data Bound control as bellow
- Since all data transaction is Asynchronous we need to attached “Selected” event handler and do the data bind where data has been retrieved.
- Lastly we need to call the request, in the constructor (or during page load)
- When you run the project, you’ll see a text = “Loading…” which i put to indicated that the data is still in process. And when the data is retrieved i changed the text to “Loaded”. Just to simulate it, in the real application you might want to put a “blocker” when the data is being load so user won’t be confused.
I’ve also attached the sample project in this link, the page that contains the sample is DataBinding.xaml, to run it change the start up page at App.xaml.cs.
private void Application_Startup(object sender, StartupEventArgs e)
{
this.RootVisual = new DataBinding();
}
Result:
Regards
Andry
Next I’ll show you how to do CRUD operation using the data source control.



























































