开发者

.NET RIA Services - work with custom data layer [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, po开发者_开发百科lling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 10 years ago.

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.


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜