开发者

WCF Data Services and Relationships in WPF?

Recently I have been working with WPF Applications that interact with server through Web Services. I am currently try to use Telerik OpenAccess to works with the database and create services for my WPF application.

However there's one problem I need to resolve and some how I can't get it to work.

The relationships in database doesn't seem to works.

I've tr开发者_运维问答ied to use WCF Endpoint Service and Data Service for .Net 4. Both have function to create a record to database like this:

service.createRecord(Record x)

My database relationship is simply have a Many to Many model like ff:

--------------
RecordID
--------------
 1
 2
 3

---------------
RecordTag
---------------
RID   |  TID  |
---------------
  1       1
  2       1
  3       1
---------------

---------------
Tag
---------------
TID 
---------------
  1
  2
  3

In my code, I did the ff:

Service.Record r = new Service.Record(){  [...] };
r.Tags.Add(new Service.Tag(){ [...] };

Result is: 1. WCF Endpoint Servicedoesn't able to add Tags because r was null. 2.Data Service for .Net 4was only addRecord` without any Tags

Anyone know how to solve this problem? Any answer or hints would be appreciated!


In the WCF Data Services case, just setting the proeprty is not enough. You need to let the context know that you want to add a link (relationship). This is because the entities do not perform property level tracking. http://msdn.microsoft.com/en-us/library/dd756361.aspx Especially the part about relationship links.


Do you mean that you can't get Record back on client? if so, have you use DataContractAttribute on your data (Record etc.) in your endpoint service?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜