Reputation: 4622
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 tried 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 add
Record` without any Tags
Anyone know how to solve this problem? Any answer or hints would be appreciated!
Upvotes: 1
Views: 463
Reputation: 13320
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.
Upvotes: 1
Reputation: 715
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?
Upvotes: 0