views:

1084

answers:

2

There is a web-application that works with Business Logic Layer (BLL). The BLL gets data from the Data Access Layer (DAL). The DAL gets data from DB through and does custom mapping.

At the moment it is required to add into the web application some functionality that will be Silverlight-based. It is planned to use .NET RIA Services for this purpose.

In the demo-video (http://silverlight.net/learn/videos/all/net-ria-services-intro/) things are very well explained:

  1. create an entity data model (using EF, for example);
  2. create a domain service using earlier create data model as data context.

I guess it is clear that it will be not a very good idea to start EF usage as data context in my case: this approach will require to work with the DB data directly skipping DAL and BLL logic.


Could you please advise:

  1. What is a better way to get SilverLight functionality on my web-site: to use RIA services or better to skip RIA services, implement own WebService that will provide the data, use this WS from the SilverLight app directly)?
  2. If we still are going to use RIA, how to create a data context that will use BLL as data source?

Any other ideas or thoughts are welcome.

Thanks.

+3  A: 

RIA Services isn't coupled to Entity Framework. You can use any DAL, including one of your own.

Specifically, instead of deriving from LinqToEntitiesDomainService, start by deriving from DomainService. You can write your query, insert, update, delete methods (depending on which ones you need), and in their implementation call out into the DAL.

The entity types can be POCO types - all they need at minimum is a one or more members marked as a [Key].

This should be enough to get you started.

Depending on your scenario this might suffice. If you've got a more sophisticated DAL, you could even create a DomainService base class customized for your DAL. Some of the reasons to do so: 1. Want to provide DAL-specific implementation of PersistChangeSet (to commit a bunch of changes to the DAL) 2. Want to translate DAL-specific metadata into DAL-agnostic metadata. Say you have a DAL-specific way of identifying what are key members, association members etc. and you want to convert DAL metadata into the equivalent [Key], [Association] etc. metadata.

Hope this helps.

NikhilK
If I correctly understand, the suggested solution is to create an empty service that will be inherited from the DomainService class... Today I've found the similar question:http://stackoverflow.com/questions/1403525/net-ria-services-and-custom-data-model-crud-capabilitiesGuess, this is enough to continue. Thanks.P.S. At the moment it is not clear for me, what is in the RIA Services better then in the simple WebService? (but probably, this will be a question for another discussion).
Budda
A: 

Hi NikhilK,

Thanks for this information. I've got my custom entity to work in Silverlight 4 using RIA Services in ASP.NET Server Application.

I've used the KeyAttribute in the DataCotract, however, I have existing objects which are DTOs (or DataContracts) and these don't have Key Attribute to them.

Does it mean I will have to change those existing DTOs? Is there another way of allowing the existing DTOs to be used??

Asif Ashrafi

Asif Ashrafi
Asif, to get answer you need to create an own topic (otherwise, nobody will answer here).
Budda