Load foreign key properties(Navigation Properities) in Silvelright WCF Ria services.

Before the code, i assume that you have created the relation ship between table in ADO.net Entities.

Here is mine,

 

CREATE TABLE [dbo].[tblRole](
[RoleID] [int] IDENTITY(1,1) NOT NULL,
[RoleName] [nvarchar](50) NOT NULL,
[IsActive] [bit] NOT NULL)

CREATE TABLE [dbo].[tblUser](
[UserID] [int] IDENTITY(1,1) NOT NULL,
[UserName] [nvarchar](50) NOT NULL,
[Password] [nvarchar](50) NOT NULL,
[RoleID] [int] NOT NULL,
[CreatedTime] [datetime] NOT NULL,
[IsActive] [bit] NOT NULL)

 

RoleID will be the foreign Key field.

 

In the entities, you need Create a navigation property against this field.

 

In domain service,

 

 

In silverlight part, you can call the service like this,

 

 

The code above is the sample everywhere people are using, i don't know whether there will be a chance that when the service loaded, but the complete event hasn't been attached to the object. For the safe operation, i think the following way is a better choice for doing this. Use CALLBACK function!!!!!

 

 

At last but not least, You must add [Include] attribute to the Navigation Property, or else, the data will not be transfered to SL client.

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值