Silverlight 3 + .NET RIA Services July Preview

An exciting set of bits become officially announced today - an amazing RIA platform, Silverlight 3, and the next update for .NET RIA Services, a framework for making n-tier data-driven apps simpler...

Silverlight v3Silverlight 3 is here!!! The Silverlight platform has come a long way (in a relatively short period of time) from a scriptable graphics and media runtime into a full-fledged platform for developing Rich Internet Applications, using managed code, the goodness of application frameworks and controls, and great tools such as Visual Studio and Expression. In my MIX ’09 post, I listed the following:

  • Graphics and Media Capabilities - GPU support, perspective transforms, pixel shader effects, media smooth streaming, new codecs, including ability to write your own, better text rendering, etc.
  • Data - Lots of new data controls (such as DataForm), data-binding improvements, and validation.
  • Application model - ability to use library cache for reducing xap package sizes, better styling and theming capabilities and support for application frameworks.
  • Out-of-browser applications - the ability to write apps that escape the browser chrome, can run offline, and across platforms.
  • Networking - besides offline/online notifications, support for binary serialization, server push and local connections (for communication across silverlight apps)

Today, all that becomes real, and available for apps to use and deploy with Silverlight 3. An exciting summer lies ahead for RIA development. Here are some interesting Silverlight feature highlight demos along with a list of all the new features.


.NET RIA Services End-to-EndIn addition, I am also working on .NET RIA Services, which is all about making typical LOB apps, and n-tier data-driven Silverlight applications much easier to build by harnessing the strengths of Silverlight on the client and ASP.NET on the server. Here is my post on the .NET RIA Services vision and high-level architecture. The July ’09 Preview has also been released, and while this obviously includes the updates to work on top of Silverlight 3 and various bug fixes, it also includes other significant feature updates. For example:

API improvements:

  • Improved DomainContext API - much more easier to issue multiple queries simultaneously, track completion, cancel requests etc. using callbacks. Also you can now see consistency with what you authored on the server DomainService (aka no more Get -> Load renaming). Yes, we heard your feedback!
  • Consistent pattern for authoring CRUD operations in the DomainService on the server.

Some new capabilities:

  • Extensibility around authentication model on the client - for example, to plug in OpenID. There are other extensibility hooks for framework authors and app authors also included in various parts of the stack on the server and on the client.
  • Ability to create n-tier class libraries. You can now have a server Class Library to put your DomainService in, link it to a Silverlight Class Library, and then reference the pair across multiple apps.
  • Initial bits of integration with ADO.NET Data Services. For example, you can now expose an explicit service by layering a DataService on top of DomainService.

Some big time cleanup:

  • Fixed the shared code model. Just put something in a .shared.cs (or .shared.vb) file, and we understand it. No need for adding the confusing [Shared] metadata attribute… in fact the attribute is simply gone!
  • Updated our code-gen to support additional partial class scenarios much more straight-forwardly such as computed properties, custom initialization logic etc.

I’ll be building an end-to-end app with .NET RIA Services that goes beyond the basic HelloWorld sample. I hope to share in the next couple of weeks over the course of a set of posts. Also look for a post on Silverlight.FX (soon), which has been updated to run and even take advantage of a couple of Silverlight 3 features.

Posted on Friday, 7/10/2009 @ 10:28 AM | #Silverlight


Comments

38 comments have been posted.

rickj

Posted on 7/10/2009 @ 12:20 PM
The .NET RIA sounds like a good idea but myself and alot of othe people are having a lot of trouble installing the .net ria services
untill you have something that will install you should be writing about installing it not developing with it how can you develop with something that won't install

Nikhil Kothari

Posted on 7/10/2009 @ 12:32 PM
If you download the bits now, they should install fine over VS 2008 + SL3.
Lots of folks were trying to download earlier when the bits weren't fully propagated yet, and were getting the older CTP instead.

Anil

Posted on 7/10/2009 @ 1:39 PM
Great work Nikhil!

Any improvements on being able to leverage the existing business objects? There are tonnes of POCO objects lying out there. Please correct me if I am wrong, but for those POCOs to integrate into RIA framework, they have to be decorated with attributes (every class must have atleast one [key] attribute etc.,]?

With beta version it did seem like EF , DomainService etc., had to be lumped into one project. One of the new capabilities "n-tier class libraries" is greatly appreciated. We can separate the data, business and UI concerns.

Please keep up the good work.

Thanks.

Soner Gönül

Posted on 7/10/2009 @ 2:56 PM
Thanx man ;)

Steve

Posted on 7/10/2009 @ 3:44 PM
Anil:

You might want to check out the metadata provider:

http://code.msdn.microsoft.com/RiaServices/Release/ProjectReleases.aspx?ReleaseId=2659

"the sample also provides a working solution to the existing problem of providing additional metadata for types that you don’t own or can’t modify. "

I assume this means key attributes as well

rickj

Posted on 7/10/2009 @ 7:10 PM
I down loaded the new bits and they work fine thanks for the great articale hope there's more to come
looking forward to this new Tech. with anything new I hope there are lots of how tos to come
Thanks

Anil

Posted on 7/10/2009 @ 8:14 PM
@Steve:

Thanks for the link Steve. It does address a workaround for the situation. Your assumption is also correct. I downloaded the sample and looked at it. Key attributes can also be added.
But imagine doing that to multiple objects. I am better off rewriting my poco classes with proper attributes (syntax and intellisense check) than having to type myriads of xml elements with typos.
My question had a different premise. Why that requirement to begin with? Is there a way to avoid relational model concepts (like keys etc.,) bleeding into the object domain realm? Could it be optional atleast?

IMHO, DomainService also seemed like it was modelled to be tightly coupled with relational models (e.g L2SProvider and EFProvider).

Or did I misunderstand the whole concept??

Nikhil Kothari

Posted on 7/11/2009 @ 2:03 AM
@Anil,
Key is not strictly something to do with the relational model, and certainly not EF or L2S.

One has to be able to identify what makes up the identity of an object in a distributed system. You have an object on one tier, with some name/values. When you transfer the set of name/values on the client, how do you know if you already have that object on the client? You need an identity. Similarly when you have related objects, and you fetch one object at one point in time, and a related object at another point in time, how do you hook the two to allow client navigation from one to the other? You need keys, and the information about the association.

We've created a small set of attributes like Key, Association etc. in the System.ComponentModel.DataAnnotations namespace to represent such concepts in a DAL-independent fashion.

These will not be optional based on the above description of scenarios causing them to be needed. Hope that explains...

Sebastijan Pistotnik

Posted on 7/11/2009 @ 4:59 AM
What did you mean by "DAL-independent fashion". Did you mean that NHibernate can also be used with RIA?
I tried to use RIA with NHibernate entities (I have a small basic demo project with select, add, edit, delete features, if you want to see it?) but it seems like Association attribute on many to one property association is not
applicable to NHibernate entities. If this is the case, than only DTO objects can be used with RIA, which makes RIA with NHibernate unusable. Correct me if I am wrong? Thanks.

shaggygi

Posted on 7/11/2009 @ 6:39 AM
Good stuff. I do have to ask the question though.... When will RIA Services support WPF apps? Any tutorials/walkthroughs in the works? Thanks

Nikhil Kothari

Posted on 7/11/2009 @ 7:57 AM
@Sebastijan
The idea is in fact to enable NHibernate to plug in as well.

For associations we need foreign keys to be in the model exposed to the client, even if they're not actually there in the underlying classes. There are some advanced extensibility hooks in RIA Services that allow the domain service to synthesize these foreign keys. This is similar to Entity Framework by the way.

I do hope to get a sample of this scenario out and available. Still looking into it...

@shaggygi
At present, we're validating our stuff on the desktop framework so it can be used with WPF, and we can provide that functionality in the future, but at the moment for v1, the focus and target client platform is Silverlight.

Anil

Posted on 7/11/2009 @ 9:16 AM
@Nikhil

Thanks for the reponse. RIA looks very very promising though.

Anil

Len

Posted on 7/11/2009 @ 1:58 PM
Silverlight installed ok, Expression Blend ran me in circles, but I finally got it downloaded from the Silverlight download page. .NET Ria, once I got the July version, installed, but no Business Application Template. I installed it several times, then tried using devenv to install the templates. The zip file is there but when, as an administrator, I run devenv /InstallVSTemplates it tells me "operation could not be completed. The requested operation requires elevation." If I use a command prompt in the IDE folder, running as Admin it executes, but still no Business App template. This is on Vista Home, I will try it Monday on my dev system (Server 2008) and see if there is any difference.

I had an almost complete database interface for a data acquistion system to support experiments, complete with graphing and found the Business App a great basis to start from. With the extent of the syntax changes it looks like it will be faster to rebuild it than try to modify it. I still think this is the best thing out of Microsoft in a long while, I am really excited about the speed that a business app can be put together. The only problems I had with the earlier release was using the combo box in a grid to index information from other tables given a key, I need to either copy data from a grid to the clipboard or to an Excel spreadsheet, and the graphs wasted too much space with the series box to the right and the markers were too big. I guess there were some problems syncing requests to the entities with the responses back at the browser I'm glad to see some changes there.

Great work all in all, Thanks, Len

Sebastijan Pistotnik

Posted on 7/12/2009 @ 5:24 PM
Let us assume we have a database with 1200 tables (we actually have a project like that), so we have for example 1000 entities. Can generating a file with those proxies become a performance problem in Visual Studio?

Nikhil Kothari

Posted on 7/12/2009 @ 9:18 PM
@Sebastijan
Before I even try answering that question, let me ask a question - do you really want to write a Silverlight client app that brings down that much data in terms of types, operations, and instances? I personally would want my SL apps to be small, nimble, and task-focused.

It would be beneficial to think what are the operations you want that match a task or set of tasks that an app needs, what are the logical set of types needed etc.

Sure you could stress test the platform and the tools, but lets think of the end-user experience, and the developer experience as well, in terms of creating usable and maintainable solutions first.

Sebastijan Pistotnik

Posted on 7/13/2009 @ 7:11 AM
Hm...Let us touch a practical application I had in mind. Let us assume the application is for healthcare institution.
I want to substitute my current windows forms application with silverlight application, since I benefit from it a lot for the
knowing reasons (from deployment to visual representations, user experience etc)... This application would be an Intranet application, so loading the application
the first time (and latency) would not be a problem.
This application has different main "modules": For example:

- Outpatients (which further has it submodules; for example admition, request etc)
- Hospital (submodules as nutrition, diets, nursing care, medical stuff etc)
- Surgery (submodules as appointments, surgical treatments, operating tables, surgical teams, schedulling, waiting lists etc)
- Reception (...)
- Diagnostic units (...)
- Administration and billing (...)
- Settings (...)
- Order management (...)
- Laboratory (jao jao jao...)

Now, every single module has as you can assume a lot of entities behind since it has submodules also, you cannot avoid that.
As I understand you, you most probably think that I should have for example Surgery module as a separate
Silverlight ("small" task focused) application (in a separate VS solution), but this is somehow difficult to achive, since
some module might need some information from other module. You cannot make them independent. You would wish of course
but in practice this cannot be achived. Perpetuum mobile:) As soon as you will achive it, I new feature request will come and you are doomed.
There is also a refactoring issue here. If you have separate solutions, I cannot refactor the code with for example Resharper tool.
So I did not want to stress-out the platform and tools although it sounded like this:), but I have a practical problem here.

It is possible that misunderstood the term "Rich". I read a heavy thesis on RIA:

http://www.flomedia.de/diploma/
http://www.flomedia.de/diploma/documents/DiplomaThesisFlorianMoritz.pdf

And I thought Silverlight RIA applications are definitely a substitute for rich and fat Desktop application. Am I wrong...hm

The term "small" is relative a think. Small quickly becomes Big especially nowdays when we must
develop every "stupid" thing an end user thinks of. I was actually asking a question because I saw you are putting all the entities and contexts
in one (generated) file. And I was thinking could that be changed for performance reasons of tools and separate it somehow. Just a thought...

Sebastijan Pistotnik

Posted on 7/13/2009 @ 7:23 AM
Or even to create a VS plugin/AddIn to enable the code generation file on demand...for example clicking a button: "Generate RIA domain contexts and entities" with a possibility to exlude
the automatic VS file generation. Just thinking:)

Nikhil Kothari

Posted on 7/13/2009 @ 7:35 AM
@Sebastijan
The thing to think about here is factoring, even if it is all a single application - the initial "shell" that stitches together these different roles/modules and provides some common contracts shared by all modules. It should be minimal and light-weight, and then based on actual usage within the session, the right modules are loaded on-demand. Each module only cares about a subset of the entire world.

One of the features that will no-doubt help in enabling and facilitating the factoring is the new class library support in RIA Services. For example, you might have a server classlibrary for a particular section/subset, and a corresponding Silverlight class library for that. Similarly you have other pairs for different pieces of functionality. Now you have the option of either deploying all the Silverlight assemblies as part of a single app package, or loaded on-demand. All the server class libraries are of course deployed into the same web application.

Hopefully this gives some pointers on things to consider... I didn't imply that large apps aren't suitable for RIA, but rather I think you want to keep end-user experience in mind. Don't make someone wait for an application to show up in the browser, in the same way they wait for an installable msi to download...

Sebastijan Pistotnik

Posted on 7/13/2009 @ 7:41 AM
Uf...one more post than I will not bother anymore hehe...But I have some experience with code generation of entities and then using such a project, and my experience might be useful.
Changing an entity is A RARE operation. The same is changing the contracts in server DomainService classes.
(Most of the time, you are dealing with GUI, or server bussiness logic, that will Never reside in a DomainService class, but in some other classes (helpers, managers, utils, queries etc).
In a DomainService class you typically just call something that executes your business and data handling logic.)

Since it is a rare operation you do not have to check, copy, parse and handle it every time if this can become a problem. That is why I think that generation on demand would be a great
solution for those small-big problems on the performance of tools subject. And creating such a AddIn is a matter of 2 hours work if you ask me:)...Just an opinion...

Nikhil Kothari

Posted on 7/13/2009 @ 8:52 AM
@Sebastijan
Good conversation :-)

There is a bit of philosophy/vision at play here - we want a domain service to be a class unlike any other in the logical client + server halves. In other words, when you author a class within a project, you don't have to do anything (not even save) to see it in intellisense within another class in the same project. The same here - we want to avoid things like add service reference, explicit steps to create proxies etc. when using a domain service. We do track when the server project changes to know whether there is any code-gen to do (eg. you're not changing server, and only working on the client half - that shouldn't incur code-gen work).

As part of integration with the underlying services stack, we will have an Add Service Reference step as well - however that works from an interop/wsdl-like basis, and as such features like shared code, metadata propagation won't happen, since its no longer happening within the scope of a single application.

Dave R.

Posted on 7/13/2009 @ 8:53 AM
I really like what I've seen with the new tooling support and additional controls for SL3. However, I also think it's a shame that this seems limited to Silverlight/WPF applications. Where's the WebForms love? ;)

It would be super to be able to prototype normal ASP.NET web apps with Sketchflow, especially when many businesses are not keen on installing new plugins on all their clients. I would have thought that many of the animation effects could already be done with jQuery or similar JS frameworks on the client. Let's face it, few business apps are going to use pixel shaders or MPEG-4 video.

Anyway, thanks for the info and congratulations on the release.

Nikhil Kothari

Posted on 7/13/2009 @ 9:01 PM
@Dave R.
I'd love to see sketchflow apply more generally to ASP.NET as well...

Sebastijan Pistotnik

Posted on 7/14/2009 @ 1:07 AM
I read about a factoring and loading on-demand issue all night. I also read Chapter 19 in new RIA documentation on new RIA services class lib.
I was quickly starting sketching my possible project/solution architecture to have in mind on-demand loading.
For example: let us assume I create 3 modules-domains:

1. Two dependant one which I cannot avoid
- HumanResources with entities as Resources, Patients, Doctors, Nurses etc, (First RIA service class Lib (2 projects))
- Hospital with entities as Nutrition, OperatingRoom that also use HumanResources (Second RIA service class Lib (+ 2 projects))
Let us assume that some other module will not be dependent on this one.
2. One independent one of the previous (hoping independent, assuming independent, closing my eyes to seeing it as independent)
- Order managament (Orders, ...) (Third RIA service class Lib (+ 2 projects))
OK...jst trying/sketching something:))

I can quickly get into the expansion of projects in my solution (which all .net community are really trying to avoid last 2 years for the knowing reasons):
"Projects" that should be "namespaces" in non-silverlight application. As I understood this resolved the shared code problem,
but the developers of RIA were also (althought they did not write that (and they should)) thinking about the factoring and loading on demand problem. I understand it somehow or at least trying hard to.
I was wondering couldn't we have another marking RIA attribute for namespaces instead of so many projects (dreaming), but even if we had, there would be a dll problem... This silverlight isn't so easy I see.
The architecture and thinking about and keeping it that way can become complex and a difficult thing. At least I think so.

Now what I really hope for is also to see some demo application not including images, videos or zooming of an image, search buttons (uf how I am alergic to that heeh), but of a "smart" architecture with on-demand solutions and handling of a huge RIA applications.
Hope this is not reserved only for big players as Microsoft, Oracle, IBM, General motors or whatever...us small companies want to have great solutions too and we have no resources to pay for special consultants for that:).

Nikhil Kothari

Posted on 7/14/2009 @ 2:56 AM
@Sebastijan
One thing to look at right now is Prism, which offers some solutions to building composite apps from a set of modules. I agree, the ability to stitch together an app from its parts, potentially some dynamically on-demand loaded is key capability for a whole set of customers.

My hope is that everything (as in every module for example) doesn't have to be in the same solution... imagine one "team" produces some bits as a classlibrary, and other projects/solutions reference that. Similarly each module doesn't see each other and can be in separate solutions. The key is to recognize what are your shared contracts, and have them be in the core assembly/project referenced by all others.

Sebastijan Pistotnik

Posted on 7/14/2009 @ 7:33 AM
Uf...super...and it even works in Silverlight 3. I already found StockTraderRIBootstrapper class that downloads remote modules and loads their Types into the application domain...looks promising...hope they will move this to use RIA. Thanks a lot!

Mark Monster

Posted on 7/14/2009 @ 11:15 AM
Hi Nikhil,

Very interesting this new preview of .NET Ria Services. Do you have a PoC of Silverlight + Ria Service + OpenID? I'm wondering how to get OpenID integrated in Silverlight, basically because OpenID is a lot about Redirections, as far as I know and remember.

-
Mark Monster

Len

Posted on 7/14/2009 @ 12:15 PM
Everything is working fine on Server 2008, I am happy to say. The first page (and children) is nearly converted over. Will you be including an example of a ComboBox using a key to pick up some data from another entity?

Vaibhav Deshpande

Posted on 7/22/2009 @ 2:16 PM
I have a scenario where I get three objects from the server (say orders) using ria. I present these 3 products in a grid. The user is allowed to make changes to the products in the grid. The user needs to select a product that he wishes to save and then click the save button to save the product. The problem is that if the user makes changes to all 3 products and intends to save only one of the three, I cant use the ria context instance that obtained the 3 products in the first place. I need to create a new context, attach the selected product to it and then submit changes. However when you attach an entity this way, it gets attached as "unmodified" and hence when I call submitchanges on the new context, it has no changes to submit to the server. How can you achieve this functionality.

Nikhil Kothari

Posted on 7/23/2009 @ 4:02 PM
@Vaibhav -
What you're trying isn't supported today. I'd recommend thinking about the UI and associated taskflow for the user. If each individual record is associated with an independent user task, then perhaps the grid isn't the best metaphor, as it represents a list. Instead use the list for selection and starting a task, and then create a different DomainContext instance for each task instance... and commit it when the task as it is done.

Vaibhav Deshpande

Posted on 7/26/2009 @ 7:13 PM
Thanks for your reply Nikhil. We had to change the application and the UI to meet the user expectations within the limits of RIA. However in our scenario it would have been ideal have a SubmitChanges method which could accept a lamda expression as a parameter and would submit just the results of the query. You said what I was trying was not submitted "Today". Does this mean that we can expect something in beta or the final release?

Nikhil Kothari

Posted on 7/26/2009 @ 9:05 PM
@Vaibhav
Pretty unlikely for v1.

The problem is its a fairly complicated capability to expose to developers - the framework implementation is not hard. For example, factor in the following - you have an entity with some related entities changed/added/deleted. Does submitting a specific entities traverse the graph? What if the entities you're associated with are also associated with other entities of the same type you're trying to submit? And finally what is the user and developer model to indicate only part of the changes have been submitted, esp. if you enable a Save button based on HasChanges, which sometimes becomes disabled, and sometimes doesn't... because the code is doing a partial submit. Hence right now, and its likely to stay that way, SubmitChanges submits everything, and you can use multiple DomainContext instances to break down your work into smaller and multiple units of work.

Hope that makes sense...

Vishal Shukla

Posted on 7/30/2009 @ 3:13 PM
Hi Nikhil,
When do you think we will get the RIA templates for studion 2010. I was going to start a new silverlight project on studi0 2010 and would love to use RIA services for that.
thanks,
Vish

Vaibhav Deshpande

Posted on 8/13/2009 @ 9:28 PM
Hi Nikhil,

We are using RIA with Entity Framework. We have close to 50 fairly large tables with an average of about 100 fields per table. When we try to bring single entities down to the client side, the response time is fairly ok. However when we include sub-objects (which are not entity lists, just parent objects), things run extremely slow. It took about 3 minutes for an object with 2 sub-objects to be brought down to the client. We ran traces and found that almost 95% of the time was spent to generate the SQL query. We confirmed this by swapping out Linq 2 Entity with Linq 2 SQL. With Linq 2 SQL the response time for the same object was 3 seconds. We tried some optimization techniques like View Generation for Entity Framework which reduced the response time from 3 minutes to 30 seconds. However thats still a lot of delay. Can you give us some tips on improving the performance with Entity Framework.

Thanks,
Vaibhav

sri

Posted on 8/20/2009 @ 1:24 AM
Unable to install silver light.coming up with "Invalid hash key"

Nikhil Kothari

Posted on 10/21/2009 @ 12:06 AM
@Vaibhav
Unfortunately I am not an expert on Entity Framework. I'd recommend an EF forum for asking such perf related questions and using EF. I personally use Linq To Sql in my demos/sample apps... it works for me.

Ganesh Jagdale

Posted on 11/23/2009 @ 11:58 PM
HI ..
Nikhil , I create a application using RIA with Fluant NHibernate. But When I doing update opration on Grid data which is get from NHibernate session that time it give me exception that " Entity set of Type Employee does not support Edit operation"
Later I specify Editable Attribute to each Propery in Employee class Still Exception is there...
Then How I going solve this problem?
please reply me.....

vinod

Posted on 1/8/2010 @ 4:25 AM
HI ..
Nikhil ,I am also facing above mentioned problem please give solution

Rajesh Sanil

Posted on 6/12/2010 @ 1:53 AM
I have on doubt while using ria service . I'm working on Inventory , with sales. My Question is When i'm saving sales invoice same time I want to Update Customer Table for their balance as well as my in ventory table to reduce the stock . is there any option like in While calling submitchanges . can we do any customization to Update other table which is in other entity model
Post your comment and continue the discussion.