惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - 叶小钗
云风的 BLOG
云风的 BLOG
G
Google Developers Blog
S
SegmentFault 最新的问题
罗磊的独立博客
Hugging Face - Blog
Hugging Face - Blog
美团技术团队
爱范儿
爱范儿
博客园 - 三生石上(FineUI控件)
H
Hackread – Cybersecurity News, Data Breaches, AI and More
D
DataBreaches.Net
F
Fortinet All Blogs
TaoSecurity Blog
TaoSecurity Blog
D
Docker
C
Cybersecurity and Infrastructure Security Agency CISA
K
Kaspersky official blog
宝玉的分享
宝玉的分享
腾讯CDC
Google Online Security Blog
Google Online Security Blog
Recorded Future
Recorded Future
T
The Exploit Database - CXSecurity.com
T
The Blog of Author Tim Ferriss
V
V2EX
S
Securelist
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
C
CERT Recently Published Vulnerability Notes
A
Arctic Wolf
Scott Helme
Scott Helme
L
LINUX DO - 热门话题
Y
Y Combinator Blog
P
Proofpoint News Feed
T
Tor Project blog
AWS News Blog
AWS News Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
The Last Watchdog
The Last Watchdog
博客园 - 聂微东
T
Threat Research - Cisco Blogs
B
Blog
Attack and Defense Labs
Attack and Defense Labs
L
Lohrmann on Cybersecurity
C
CXSECURITY Database RSS Feed - CXSecurity.com
阮一峰的网络日志
阮一峰的网络日志
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
IT之家
IT之家
N
News and Events Feed by Topic
博客园 - 司徒正美
H
Help Net Security
C
Cisco Blogs
C
Check Point Blog
S
Secure Thoughts

博客园 - yo

Silverlight 缺陷 - yo - 博客园 SilverLight Controls WF 4.0 中 Persistence 异常 - yo SilverLight框架初探-View - yo - 博客园 SilverLight框架初探-ViewModel SilverLight框架初探 与客户“调情” AG_E_PARSER_BAD_PROPERTY_VALUE 定义属于自己的Routing 数据契约的序列化 WCF客户端配置问题 关闭EXCEL进程 母版页中控件ID获取 - yo - 博客园 Reportviewer - Error: ASP.NET session has expired - yo SQL CLR C# DLL动态调用 Sharepoint List faults - yo 出错页面webpar的t删除 quickpart
SilverLight框架初探-RiaService
yo · 2010-03-15 · via 博客园 - yo

上一篇介绍了ViewModel,下面介绍一下结构中RiaService。

在.net 4.0中,为我们提供了一个新的Ria服务:Domain Service,主要用于处理SilverLight与服务端的通信问题。以往我们在处理这方面的问题时,首先想到的是用WCF、Web Service等方式来实现,所以在处理过程中还需要去考虑通信方面的问题。但有了Domain Service后,我们不用再去关心这方面的问题,它会自动帮我们生成相应的通信协议与代码,将我们所提供的服务曝露给Silverlight客户端。

DtoModels,用于存放于View相对应的视图模型类;

TesstDomainService,用于实现RiaService的Domain Service类

代码如下:

[EnableClientAccess()]
    public class TestDomainService : DomainService  // LinqToEntitiesDomainService<TestEntities>
    {

        // TODO: Consider
        // 1. Adding parameters to this method and constraining returned results, and/or
        // 2. Adding query methods taking different parameters.
        private IProduction _iProduction;   

        public TestDomainService()
        {
            _iProduction = new Production();
        }

        public IQueryable<ProductionDataDto> GetProductionData()
        {
             List<ProductionData> viewModel = _iProduction.GetProductionData();
            IEnumerable<ProductionDataDto> viewModelDto = (from table in viewModel select new ProductionDataDto())
            return viewModelDto.AsQueryable();
        }
    }

这里,我们继承自DomainService,这样就可以实现WCF的功能。同时定义了一个IProduction接口,通过它来实现数据服务功能,我们可以通过Ado.net entity data或者Linq to database等方式来与数据库进行交互。ProductionDataDto为与ProductionData相对应的视图模型类,在从数据服务层返回数据实体模型ProductionData后,需要转换为页面所需要的视图模型。