locked
Client libray seems not to work well to update many to many relations back to DB RRS feed

  • Question

  • Hi,

    I have a list box with a list of work groups. This will be used to updated a many to many relation in the database -  many user-----many workgroups

    tblUser-------tblWorkgroups

    The EF does not show the mapping table since it only has two Ids from tblUser and tblWorkgroup

    I am using the client proxy provided by WCF Data Service to delete or add users to work groups and then just call the ctx.BeginSaveChanges. 

    In most scenarios the code below is working.

    However, sometimes it throws an error and I cannot figure out why. The error clearly states that there is a primary key violation.

    <message>Violation of PRIMARY KEY constraint 'PK_tblUserInWorkgroup'. Cannot insert duplicate key in object 'dbo.tblUserInWorkgroup'.&#xD;

    I do not understand why this is happening since I am deleting all the links before setting them back. 

    ctx.DeleteLink(user, "tblWorkgroups", wg);
    user.tblWorkgroups.Clear();
    ctx.UpdateObject(user)

    Or there could be a problem with the IEnumerable<LinkDescriptor>.. Not sure.

    I was wondering if someone more experienced could have a look at the code below and spot why I get an exception?

    private void Button_Click(object sender, RoutedEventArgs e)
    {
                foreach (var wg in user.tblWorkgroups)
                {
                    ctx.DeleteLink(user, "tblWorkgroups", wg);
                }
               
                user.tblWorkgroups.Clear();
                ctx.UpdateObject(user);

                foreach (var wg in lstBoxWorkGroup.SelectedItems)
                {
                    IEnumerable<LinkDescriptor> existingLinks = ctx.Links.Where<LinkDescriptor>(l => l.Target == (tblWorkgroup)wg);
                    if (existingLinks.Count<LinkDescriptor>() == 0)
                    {
                        ctx.AddLink(user, "tblWorkgroups", (tblWorkgroup)wg);
                    }
                    else
                    {
                        LinkDescriptor link = existingLinks.First<LinkDescriptor>();
                        ctx.DetachLink(link.Source, link.SourceProperty, link.Target);
                    }
                }
                ctx.BeginSaveChanges(SaveChangesOptions.Batch, PersistChanges, null);
            }

    Cheers

    C

    Tuesday, June 21, 2011 11:49 AM

All replies

  • any ideas?
    Tuesday, June 21, 2011 3:50 PM
  • Claudio, the code snippet you have above looks fine, there is nothing there that jumps out to me as the reason you are getting the error. The error sounds like its data dependent though so if you can narrow the repro down and find out what the data in your database needs to look like to hit this error it might help us track your issue down - if you can narrow it down to just a couple entities with a couple of links between them you could take a fiddler trace of the BeginSaveChanges call and post that and that would give us some idea what is happening under the cover. Right now there isn't enough information to help us get to the root cause.


    Shayne Burgess | Program Manager | OData/WCF Data Services
    Wednesday, June 22, 2011 5:25 PM
    Moderator
  • Hi Shayne,

    Thanks a lot for your reply and help. I really appreciate it.

    Tomorrow I will run fiddler and see if I can get more info to provide. This is a really important issue for me to solve.

    I have tried creating a server side method to perform this operation in my WCF Data Service and hard coded the parameters to call the method. This worked.

    Basically, I pass a USER ID and a comma delimited list of WorkGroup IDs and insert them into the mapping table tblUserInWorkgroup.

    It is called with something like this: SaveUserToWorkgroups(40, "22,34,5")

    This is the full method code. Does it help to find what is wrong with the client side code above?

    However, I would like to use the client library to save changes and not have a service operation.

    [WebInvoke]
            public IQueryable<tblUserInWorkgroup> SaveUserToWorkgroups(int userId, string workGroupIds)
            {
                try
                {
                    tblUser user = CurrentDataSource.tblUsers.Where(c => c.UserId ==
                        userId).FirstOrDefault();

                    var idList = from id in workGroupIds.Split(',')
                                 select int.Parse(id.Trim());

                    if (user != null)
                    {
                        user.tblUserInWorkgroups.Load();
                        foreach (var workgroupId in idList)
                        {
                            if (user.tblUserInWorkgroups.Where(c => c.WorkgroupId == workgroupId).FirstOrDefault() == null)
                            {
                                tblUserInWorkgroup newUserInWorkgroup = tblUserInWorkgroup.CreatetblUserInWorkgroup(user.UserId, workgroupId);
                                CurrentDataSource.AddTotblUserInWorkgroups(newUserInWorkgroup);
                            }
                        }
                        CurrentDataSource.SaveChanges();
                    }

                    var coll = from uwg in CurrentDataSource.tblUserInWorkgroups
                               where uwg.UserId == userId
                               select uwg;

                    return coll;
                }
                catch (Exception)
                {

                    return null;
                }
            }

    2 - One thing that occurred to me is that what if the client code does not delete the the object before trying to insert it? I have tried to delete it before but does it work?

    Is there a way I can hook to the lifecycle of the client library and WCF Data Service to see what is going on?

    Cheers

    C

    Wednesday, June 22, 2011 9:27 PM
  • Hi Shayne,

    I have read the MSDN documentation about the client library but I still do not understand some aspects of it and I would like to ask you some questions. Please see below.

    This is how the database is structured

    tblUser ------> tblUserInWorkgroup <--------- tblWorkgroup. The mapping table tblUserInWorkgroup has only two fields UserID and WorlgroupID.

    Therefore, the entity framework hides the mapping table and the model looks like this:

    tblUser --------- tblWorkgroup . So many users can belong to one workgroup and one workgroup can have many users.

    1 - Could you please explain to me the difference between DeleteLink and DetachLink?

    2 - In the code below, for each tblWorkgroups that the user belongs to, I delete the link. I suppose this is deleting the mapping table tblUserInWorkgroup. Is my assumption right?

    3 - Also, I assume that it is deleting only in memory. We have not hit the database yet, right?

    4 - What happens when I call ctx.UpdateObject(user) ? Does it go to the database at this point?

    foreach (var wg in user.tblWorkgroups)
                {
                    ctx.DeleteLink(user, "tblWorkgroups", wg);
                }
               
                user.tblWorkgroups.Clear();
                ctx.UpdateObject(user);

     

    5 - Why do I have to use a LinkDescriptor here?

    Cheers

    C

    Thursday, June 23, 2011 8:52 AM
  • Hi,

    1) DeleteLink will remove the link/relationship from the data. DetachLink only makes the client forget about the link, it does NOT remove it from the data (this operation doesn't mark anythign as dirty). So to modify data use DeleteLink. DetachLink is usefull in some "advanced" scenarios, for example if you made the link dirty and then want to make the client forget that you did so.

    2) Well it should not delete the table itself, it should delete one row from it.

    3) Yes DeleteLink only marks the link on the client for deletion, there's no communication with the server there.

    4) UpdateObject marks the entity itself as dirty, since the client does not do propety level tracking, changing a property value on an entity usually doesn't mark anything as dirty. UpdateObject is the method to do that programatically. It means that the client will send a PUT/MERGE for the entity in the next SaveChanges call. Just like DeleteLink, this is all in-memory, client-side operation. It does NOT go to the database. Only SaveChanges actually sends the updates to the server and the DB.

    5) I don't understand the question, could you please describe what you're looking for?

    Thanks,


    Vitek Karas [MSFT]
    Thursday, June 23, 2011 3:10 PM
    Moderator
  • Hi Vitek,

    Your wrote:

    5) I don't understand the question, could you please describe what you're looking for?

    In this extract of the code in my first post, you will see that I am using LinkDescriptor and in the else clause I am using ctx.DetachLink

    1 - Should I be using DeleteLink here instead?

    foreach (var wg in lstBoxWorkGroup.SelectedItems)
                {
                    IEnumerable<LinkDescriptor> existingLinks = ctx.Links.Where<LinkDescriptor>(l => l.Target == (tblWorkgroup)wg);
                    if (existingLinks.Count<LinkDescriptor>() == 0)
                    {
                        ctx.AddLink(user, "tblWorkgroups", (tblWorkgroup)wg);
                    }
                    else
                    {
                        LinkDescriptor link = existingLinks.First<LinkDescriptor>();
                        ctx.DetachLink(link.Source, link.SourceProperty, link.Target);
                    }
                }
                ctx.BeginSaveChanges(SaveChangesOptions.Batch, PersistChanges, null);

    2 - I got this piece of code from a demo but I am not sure I understand the use of LinkDescriptor. Could you please explain that to me?

    What does this mean?  ctx.DetachLink(link.Source, link.SourceProperty, link.Target);

    I have tried to find more info about LinkDescriptor but could not find any.

    I whish I could read a tutorial that would offer all this information and show us how to use the client library with real scenarios like this.

    Cheers

    C

    Thursday, June 23, 2011 4:49 PM
  • Hi,

    I was reading about the DataServiceCollection<T> and it seems that it handles links automatically in that I do not need to call AddLink/DeleteLink/etc..

    Since I am using DataServiceCollection<T> to loadAsync all my entities, could that be the reason my code doesn't always work?

    I have two questions:

    1 - How could I manipulate the object graph directly with the DataServiceCollection<T> ?

    2 - How do I get to the object Properties of the Target property of the ctx.Links? This l.Target.WorkgroupId does not work.

    IEnumerable<LinkDescriptor> existingLinks = ctx.Links.Where<LinkDescriptor>(l => l.Target.WorkgroupId == (tblWorkgroup)wg.WorkgroupId);

     

     

    Friday, June 24, 2011 12:08 PM
  • Hi Shayne,

    You said:

    "take a fiddler trace of the BeginSaveChanges call and post"

    What is the best way to get fiddler to cooperate and take the trace?

    I am using IIS Express. I open Fiddler and then run my Silverlight application using F5. But Fiddler does not record the trace for the BeginSaveChanges method.

    Do I have to do anything special to get fiddler to work?

    Cheers

    C

    Friday, June 24, 2011 12:35 PM
  • Hi

    I managed to get fiddler to trace by adding a dot. localhots.fiddler:....

    There seems to be a problem when I run the app with flidder tracing. Before I even get to the BeginSaveChanges method the app breaks.

    This is the code where it breaks:

    private void cbxUsers_SelectionChanged(object sender, SelectionChangedEventArgs e)
    {
                ComboBox cbx = sender as ComboBox;
                if (cbx != null)
                {
                    if (((tblUser) cbx.SelectedItem) != null)
                    {
                        user = null;
                        user = (tblUser) cbx.SelectedItem;
                        ctx.BeginLoadProperty(user, "tblWorkgroups", SelectedUsersWorkgroupLoadCompleted, null);
                    }
                }
    }

    private void SelectedUsersWorkgroupLoadCompleted(IAsyncResult asr)
    {
                ctx.EndLoadProperty(asr);

                lstBoxWorkGroup.SelectedItems.Clear();

                foreach (var wg in user.tblWorkgroups)
                {
                    lstBoxWorkGroup.SelectedItems.Add(wg);
                }

    This is what I get in fiddler. Can you shed some light about what is going on?

    http://localhost:3096/WorkGroupDataService.svc/$batch

    POST http://localhost:3096/WorkGroupDataService.svc/$batch HTTP/1.1

    Accept-Charset: UTF-8

    Accept-Language: en-gb,fr;q=0.5

    dataserviceversion: 1.0;NetFx

    Accept: application/atom+xml,application/xml

    Content-Type: multipart/mixed; boundary=batch_d07c4b14-6146-44da-965f-f9f653ca37e5

    maxdataserviceversion: 2.0;NetFx

    Referer: http://localhost.fiddler:3096/MARSWorkGroupAdminNoMapTableTestPage.aspx

    Accept-Encoding: gzip, deflate

    User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 1.1.4322; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C; .NET4.0E; MS-RTC LM 8)

    Host: localhost:3096

    Content-Length: 2267

    Connection: Keep-Alive

    Pragma: no-cache

    --batch_d07c4b14-6146-44da-965f-f9f653ca37e5

    Content-Type: multipart/mixed; boundary=changeset_8e505362-3b4d-402f-9730-1c5f8344a6f7

    --changeset_8e505362-3b4d-402f-9730-1c5f8344a6f7

    Content-Type: application/http

    Content-Transfer-Encoding: binary

    MERGE http://localhost:3096/WorkGroupDataService.svc/tblUsers(240) HTTP/1.1

    Content-ID: 72

    Content-Type: application/atom+xml;type=entry

    Content-Length: 1748

    <?xml version="1.0" encoding="utf-8" standalone="yes"?>

    <entry xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns="http://www.w3.org/2005/Atom">

    <category scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" term="MarsMedicalModel.tblUser" />

    <title />

    <author>

    <name />

    </author>

    <updated>2011-06-24T12:58:24.5914957Z</updated>

    <id>http://localhost:3096/WorkGroupDataService.svc/tblUsers(240)</id>

    <content type="application/xml">

    <m:properties>

    <d:BadLoginAttempts m:type="Edm.Int32">0</d:BadLoginAttempts>

    <d:Comment m:null="true" />

    <d:CompanySubscriberId m:type="Edm.Int32">10197</d:CompanySubscriberId>

    <d:CultureID m:type="Edm.Int32">1</d:CultureID>

    <d:Email>Afriedman@abelson-taylor.com</d:Email>

    <d:FaxNumber>(312) 894-5691</d:FaxNumber>

    <d:FirstName>Alyssa</d:FirstName>

    <d:InsertionTransactionsXML m:null="true" />

    <d:IsAnonymous m:type="Edm.Boolean" m:null="true" />

    <d:IsLockedOut m:type="Edm.Boolean" m:null="true" />

    <d:JobTitle>TBA</d:JobTitle>

    <d:LastLoginDate m:type="Edm.DateTime">2010-08-10T20:42:29.99</d:LastLoginDate>

    <d:LastName>Friedman</d:LastName>

    <d:LocationId m:type="Edm.Int32">8600</d:LocationId>

    <d:Password m:type="Edm.Binary">NzI2RDUwNzQyRENFRjY4QTE3RkFBOTIxQkQ1OTI5QzQzODMxNDlDQTdGNEQ5NjVBREM1OTJEQjcyMjc2NTQ2Qg==</d:Password>

    <d:PhoneNumber>(312) 894-5952</d:PhoneNumber>

    <d:PreferenceXML>&lt;UserPreferences&gt;&lt;/UserPreferences&gt;</d:PreferenceXML>

    <d:UserId m:type="Edm.Int32">240</d:UserId>

    </m:properties>

    </content>

    </entry>

    --changeset_8e505362-3b4d-402f-9730-1c5f8344a6f7--

    --batch_d07c4b14-6146-44da-965f-f9f653ca37e5--

    Response

    HTTP/1.1 202 Accepted

    Cache-Control: no-cache

    Content-Length: 491

    Content-Type: multipart/mixed; boundary=batchresponse_89b5a5b5-90d7-4b69-8c07-fdb53a2d4f99

    Server: Microsoft-IIS/7.5

    DataServiceVersion: 1.0;

    X-AspNet-Version: 4.0.30319

    X-SourceFiles: =?UTF-8?B?QzpcZGV2XE1BUlNXb3JrR3JvdXBBZG1pbk5vTWFwVGFibGVcTUFSU1dvcmtHcm91cEFkbWluTm9NYXBUYWJsZS5XZWJcV29ya0dyb3VwRGF0YVNlcnZpY2Uuc3ZjXCRiYXRjaA==?=

    X-Powered-By: ASP.NET

    Date: Fri, 24 Jun 2011 12:58:44 GMT

    --batchresponse_89b5a5b5-90d7-4b69-8c07-fdb53a2d4f99

    Content-Type: multipart/mixed; boundary=changesetresponse_ba8c9786-5b1f-49fa-9694-509257fa991e

    --changesetresponse_ba8c9786-5b1f-49fa-9694-509257fa991e

    Content-Type: application/http

    Content-Transfer-Encoding: binary

    HTTP/1.1 204 No Content

    Content-ID: 72

    Cache-Control: no-cache

    DataServiceVersion: 1.0;

    --changesetresponse_ba8c9786-5b1f-49fa-9694-509257fa991e--

    --batchresponse_89b5a5b5-90d7-4b69-8c07-fdb53a2d4f99--

     

    Friday, June 24, 2011 1:07 PM
  • The $batch seems OK to me, it sends a single MERGE request (update) to an entry of type MarsMedicalModel.tblUser with its primary key value 240. It gets back a response 204, which means the update was successfully applied.

    As for the query request failure, if you say "It doesn't work" it's impossible for us to figure out what's wrong. Please be more specific. If you get an exception post the exception along with its stack trace. If you don't get one, describe what is the intended behavior and what is tha actually (presumably faulty) behavior.

    Thanks,


    Vitek Karas [MSFT]
    Monday, June 27, 2011 8:11 AM
    Moderator
  • Hi Vitek,

    What I tried to explain above is that I cannot use Fiddler to trace my call to BeginSaveChanges because for some reason it breaks the application before I get to this method. For some reason adding this localhots.fiddler:.... to the url breaks the normal workflow of the app.

    If remove the .fiddler bit then I get all the way to the BeginSaveChanges() method.

    Actually, the only thing I need is to get my many to many update/delete/insert to work using the client library.

    I did not realise it was so difficult to get information about how to use the client library to perform such an operation. I posted to this forum in a hope that you guys (GURU in WCF Data Service) could help me but I have had this question open for many weeks and was not able to fix it.

    Therefore, I have decided to change the way I have phrased my question to see if it becomes clearer in general terms what I have to do. Please see below:

    My database structure looks like this:

    User ----> UserWorkgroup <----- Workgroup

    User Table
    +------------+
    | UserID      |
    +------------+
    | UserName |
    +------------+

    UserWorkgroup Table
    +---------------+
    | UserID          |
    +---------------+
    | WorkgroupID |
    +---------------+

    Workgroup table
    +-------------------+
    | WorkgroupID     |
    +-------------------+
    | WorkgroupName |
    +-------------------+

    The Entitty Framework model hides the mapping table (that is fine) and I have a many to many relationship

    User ---- Workgroup

    The Problem
    --------------

    I load a list of all Worgroups using DataServiceCollection<Workgroup> and populate a ListBox.


    I load a list of users using a DataServiceCollection<User> and display in a combo box.

    When the combo box selection changed event is fired, I highlight the Workgroups in the ListBox that the user belongs to based on the mapping table. This works fine.

    private void cbxUsers_SelectionChanged(object sender, SelectionChangedEventArgs e)
    {
                ComboBox cbx = sender as ComboBox;
                if (cbx != null)
                {
                    if (((tblUser) cbx.SelectedItem) != null)
                    {
                        user = null;
                        user = (tblUser) cbx.SelectedItem;
                        ctx.BeginLoadProperty(user, "tblWorkgroups", SelectedUsersWorkgroupLoadCompleted, null);
                    }
                }
    }

    private void SelectedUsersWorkgroupLoadCompleted(IAsyncResult asr)
    {
                ctx.EndLoadProperty(asr);

                lstBoxWorkGroup.SelectedItems.Clear();

                foreach (var wg in user.tblWorkgroups)
                {
                    lstBoxWorkGroup.SelectedItems.Add(wg);
                }
    }

    Now when the user selects or unselects items in the ListBox, I need to update the database using the WCF Data Services. That is where the problem starts.

    private void Button_Click(object sender, RoutedEventArgs e)
    {
                
                //remove all existing user/worgroup links
                foreach (var wg in user.tblWorkgroups)
                {
                    ctx.DeleteLink(user, "tblWorkgroups", wg);
                }
               
                user.tblWorkgroups.Clear();
                ctx.UpdateObject(user);

                // for each selected items in ListBox add link between User/Workgroup and Save to DB
                foreach (var wg in lstBoxWorkGroup.SelectedItems)
                {
                    IEnumerable<LinkDescriptor> existingLinks = ctx.Links.Where<LinkDescriptor>(l => l.Target == (tblWorkgroup)wg);

                    if (existingLinks.Count<LinkDescriptor>() == 0)
                    {
                        ctx.AddLink(user, "tblWorkgroups", (tblWorkgroup)wg);
                    }
                    else
                    {
                        LinkDescriptor link = existingLinks.First<LinkDescriptor>();
                        ctx.DetachLink(link.Source, link.SourceProperty, link.Target);
                    }
                }

                ctx.BeginSaveChanges(SaveChangesOptions.Batch, PersistChanges, null);
    }

    Could someone explain to me how to Add/Delete/Update the database using the Silverlight client library that WCF Data Service generates upon the service reference?

    Cheers

    Claudio

    Monday, June 27, 2011 6:23 PM
  • Hi,

    I have tried changing the foreach loop as follows:

    1 - Got this error: The context is already tracking the relationship.

    foreach (var wg in lstBoxWorkGroup.SelectedItems)
    {
            ctx.AddLink(user, "tblWorkgroups", (tblWorkgroup)wg);
    }

    2 - Got this error: SetLink method only works when the sourceProperty is not a collection.

    foreach (var wg in lstBoxWorkGroup.SelectedItems)
    {
            ctx.SetLink(user, "tblWorkgroups", (tblWorkgroup)wg);}
    }

    I was wondering if someone could come up with a simple code demo we could donwload to show how to use the client library in Silverlight to perform CRUD operation using Many to Many and One to Many relationships in WCF Data Services. I think the whole community could benefit from that.

    Cheers

    Claudio

    Monday, June 27, 2011 8:19 PM
  • Hi,

    I still have not figure out how to fix this issue. I would appreciate any help.

    Cheers

    C

     

    Wednesday, June 29, 2011 9:30 AM
  • I finally managed to use Web Developer Helper to trace the call to the save operation.

    I select an item in the ListBox and click the save button. However, it is not being saved to the database.

    Can anyone spot why it is not being saved?

    Cheers

    Here is the full trace:

    http://localhost:3096/WorkGroupDataService.svc/$batch

    REQUEST BODY

    --batch_2b7be71a-151e-410e-aac1-0c6ddccdc8f5
    Content-Type: multipart/mixed; boundary=changeset_9bf3f5ea-2b3a-4649-b9e2-5675af6ee48c

    --changeset_9bf3f5ea-2b3a-4649-b9e2-5675af6ee48c
    Content-Type: application/http
    Content-Transfer-Encoding: binary

    MERGE http://localhost:3096/WorkGroupDataService.svc/tblUsers(40) HTTP/1.1
    Content-ID: 187
    Content-Type: application/atom+xml;type=entry
    Content-Length: 4205

    <?xml version="1.0" encoding="utf-8" standalone="yes"?>
    <entry xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns="http://www.w3.org/2005/Atom">
      <category scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" term="MarsMedicalModel.tblUser" />
      <title />
      <author>
        <name />
      </author>
      <updated>2011-06-30T13:54:41.5634686Z</updated>
      <id>http://localhost:3096/WorkGroupDataService.svc/tblUsers(40)</id>
      <content type="application/xml">
        <m:properties>
          <d:BadLoginAttempts m:type="Edm.Int32">0</d:BadLoginAttempts>
          <d:Comment m:null="false" />
          <d:CompanySubscriberId m:type="Edm.Int32">592</d:CompanySubscriberId>
          <d:CultureID m:type="Edm.Int32">1</d:CultureID>
          <d:Email>claudio.pallone@kmrsoftware.com</d:Email>
          <d:FaxNumber>0208433555</d:FaxNumber>
          <d:FirstName>Claudio</d:FirstName>
          <d:InsertionTransactionsXML>&lt;InsertionTransactions email="claudio.pallone@kmrsoftware.com" accountsys="DDS" accountname="LLNS"&gt;&lt;InsertionTransaction type="order" date="2011-06-30 1:32:31 PM"&gt;&lt;Insertions&gt;&lt;Insertion name="insertionOrder"&gt;&lt;Schedule id="10164" name="Signer shed" /&gt;&lt;Vehicle key="AMER_FAMILY_PHYSICIAN" name="American Family Physician" mediaCode="AFP" /&gt;&lt;AdPage id="300" name="Page 4 Color Bleed" /&gt;&lt;Version id="490" name="11111:12121" headline="Aspirin Work" /&gt;&lt;Issue date="2011-07-01" isMonthly="false" /&gt;&lt;Rate value="11806.50" rateType="standard" /&gt;&lt;Position id="0" name="" /&gt;&lt;OrderNumber value="77" orderedByUser="true" userName="" changed="0" pos="0" freq="0" rcd="0" manrate="0" ad="0" bucket="1" /&gt;&lt;Media name="Am Acad of Family Physicians" contact="Bret Taylor" address1="11400 Tomahawk Creek Parkway" address2="" city="Leawood" state="Kansas" postCode="66211" tel="913-906-6000  5141" fax="913-906-6080" email="btaylor@aafp.org" /&gt;&lt;Agency id="593" name="KMR MARS Medical" address1="26-30 Uxbridge Road" address2="" city="Ealing" state="London" postcode="W5 2BP" tel="020-8433-4005" fax="020-8433-4003" /&gt;&lt;Issued date="2011-06-30" /&gt;&lt;Client name="aaaaa" id="6289" /&gt;&lt;Product name="signer" /&gt;&lt;EarnedBW value="1" /&gt;&lt;EarnedColour value="1" /&gt;&lt;CurrencyType value="2" /&gt;&lt;Cost value="13890.00" /&gt;&lt;LessNet value="2083.5" /&gt;&lt;AdjustedCost value="11806.5" /&gt;&lt;LessCorpDiscount value="0" /&gt;&lt;MaterialFrom value="Materials to follow" type="string" /&gt;&lt;PubCode value="AFP" /&gt;&lt;MedVenTpCode value="" /&gt;&lt;AimMediaName value="" /&gt;&lt;PubAccCode value="" /&gt;&lt;/Insertion&gt;&lt;/Insertions&gt;&lt;Header&gt;&lt;BuyingAgency id="" /&gt;&lt;Buyer id="" /&gt;&lt;Client code="111" /&gt;&lt;Product code="PAC" /&gt;&lt;Estimate number="SAC" /&gt;&lt;Updates value="N" /&gt;&lt;FullName first="Claudio" last="Pallone" /&gt;&lt;/Header&gt;&lt;/InsertionTransaction&gt;&lt;/InsertionTransactions&gt;</d:InsertionTransactionsXML>
          <d:IsAnonymous m:type="Edm.Boolean">false</d:IsAnonymous>
          <d:IsLockedOut m:type="Edm.Boolean">false</d:IsLockedOut>
          <d:JobTitle>Analyst</d:JobTitle>
          <d:LastLoginDate m:type="Edm.DateTime">2011-06-30T11:03:42.653</d:LastLoginDate>
          <d:LastName>Pallone</d:LastName>
          <d:LocationId m:type="Edm.Int32">594</d:LocationId>
          <d:Password m:type="Edm.Binary">NTJDQUJEMEI1QzJFQzc5NzE3ODNDQjcxMUM2QjBGMTdYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWA==</d:Password>
          <d:PhoneNumber>0208433444</d:PhoneNumber>
          <d:PreferenceXML>&lt;UserPreferences xmlns=""&gt; &lt;PreferedCulture value="en-US " cultureId="1" cultureName="English (US)" /&gt; &lt;TimeZone value="" /&gt; &lt;PanelAnimation value="0" /&gt; &lt;EmailAddress value="claudio.pallone@kmrsoftware.com" /&gt; &lt;FirstName value="Claudio" /&gt; &lt;LastName value="Pallone" /&gt; &lt;JobTitle value="Analyst" /&gt; &lt;PhoneNumber value="0208433444" /&gt; &lt;FaxNumber value="0208433555" /&gt; &lt;/UserPreferences&gt;</d:PreferenceXML>
          <d:UserId m:type="Edm.Int32">40</d:UserId>
        </m:properties>
      </content>
    </entry>
    --changeset_9bf3f5ea-2b3a-4649-b9e2-5675af6ee48c
    Content-Type: application/http
    Content-Transfer-Encoding: binary

    POST http://localhost:3096/WorkGroupDataService.svc/tblUsers(40)/$links/tblWorkgroups HTTP/1.1
    Content-ID: 188
    Content-Type: application/xml
    Content-Length: 205

    <?xml version="1.0" encoding="utf-8" standalone="yes"?>
    <uri xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">http://localhost:3096/WorkGroupDataService.svc/tblWorkgroups(49)</uri>
    --changeset_9bf3f5ea-2b3a-4649-b9e2-5675af6ee48c--
    --batch_2b7be71a-151e-410e-aac1-0c6ddccdc8f5--

    +++++++++++++++++++++++++++++++++++++++++++++++++++++++

    RESPONSE CONTENT

    --batchresponse_7fe1bbcf-21b6-40c2-9f48-51f090307955
    Content-Type: multipart/mixed; boundary=changesetresponse_1cc3310b-1d3c-47d2-97b8-7af006228dd4

    --changesetresponse_1cc3310b-1d3c-47d2-97b8-7af006228dd4
    Content-Type: application/http
    Content-Transfer-Encoding: binary

    HTTP/1.1 204 No Content
    Content-ID: 187
    Cache-Control: no-cache
    DataServiceVersion: 1.0;


    --changesetresponse_1cc3310b-1d3c-47d2-97b8-7af006228dd4
    Content-Type: application/http
    Content-Transfer-Encoding: binary

    HTTP/1.1 204 No Content
    Content-ID: 188
    Cache-Control: no-cache
    DataServiceVersion: 1.0;

    --changesetresponse_1cc3310b-1d3c-47d2-97b8-7af006228dd4--
    --batchresponse_7fe1bbcf-21b6-40c2-9f48-51f090307955--

     

    Thursday, June 30, 2011 1:59 PM