locked
Case sensitive URL's in the DataServices Client RRS feed

  • General discussion

  • I ran into a problem today with context tracking of some static data type entities.  It would seem that the DataServices client will load the entities into the context using the Url for the identity as defined by the client in the request, for example it will use 

    http://localhost/myserver/service.svc/Country('NZ')

    whereas if it loads the entity via an Expand clause and the entity is therefore not at the root level of the request then the client uses the identity returned on reponse.  But the response Url is defined by the server so it comes out like:

    http://localhost/MyServer/Service.svc/Country('NZ')

    This causes a problem because the context will track both of these and does not see them as the same entity.

    Has anyone else noticed this?

    Monday, January 25, 2010 1:15 AM

All replies

  • Hello Jif,

     

    I tried to repro this issue at my lab, but with no avail.  The two URL will let the context track the same entity based on my test. 

    =============================================================================================

    Uri baseUri = new Uri("http://localhost/WebDataService1.svc/");

    TestDBEntities context = new TestDBEntities(baseUri);

    var entity1 = context.Execute<Country>(new Uri("http://localhost/WebDataService1.svc/Country('USA')", UriKind.Absolute)).First();

    var entity2 = context.Execute<Country>(new Uri("http://localhost/webdataservice1.svc/Country('USA')", UriKind.Absolute)).First();

     

    MessageBox.Show(context.Entities.Count.ToString());

    =============================================================================================

     

    Could you please provide us with more detailed information about how do you see this issue at the ADO.NET Data Service client? 

     

    Have a nice day!

     

     

    Best Regards,
    Lingzhi Sun

    MSDN Subscriber Support in Forum

    If you have any feedback on our support, please contact msdnmg@microsoft.com


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Tuesday, January 26, 2010 4:46 AM
    Moderator
  • Assuming your service is named WebDataService1 (with that case) then change the baseUri, remove the first data call and follow up the second with an expand, e.g.

    Uri baseUri = new Uri("http://localhost/webdataservice1.svc/");

    TestDBEntities context = new TestDBEntities(baseUri);

    var entity2 = context.Execute<Country>(new Uri("http://localhost/webdataservice1.svc/Country('USA')"UriKind.Absolute)).First();

    var entity3 = context.Execute<Customer>(new Uri("http://localhost/webdataservice1.svc/Customer(1)?expand=Country"UriKind.Absolute)).First();

     

    MessageBox.Show(context.Entities.Count.ToString());


    Have a look at the identity on the EntityDescriptor and see what casing is used.  I think that will do it, if not then I'll make up a demo.

    Thanks
    Tuesday, January 26, 2010 8:23 AM
  • Hello Jif,

     

    If it is convenient, could you please send me a demo?  My mail address is v-micsun@microsoft.com.   Thanks a lot! 

     

    Have a nice day!

     

     

    Best Regards,
    Lingzhi Sun

    MSDN Subscriber Support in Forum

    If you have any feedback on our support, please contact msdnmg@microsoft.com


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Wednesday, January 27, 2010 8:32 AM
    Moderator
  • Hello Jif,

    How is the problem now?   If you need any further assistance, please feel free to let me know.

     

    Have a nice day!

     

     

    Best Regards,
    Lingzhi Sun

    MSDN Subscriber Support in Forum

    If you have any feedback on our support, please contact msdnmg@microsoft.com


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Monday, February 1, 2010 1:03 AM
    Moderator
  • just looked at the thread and it looks like my sample code was a bit difficult to read.

    Uri baseUri = new Uri("http://localhost/webdataservice1.svc/");

    TestDBEntities context = new TestDBEntities(baseUri);

    var entity2 = context.Execute<Country>(new Uri("http://localhost/webdataservice1.svc/Country('USA')", UriKind.Absolute)).First();
    var entity3 = context.Execute<Customer>(new Uri("http://localhost/webdataservice1.svc/Customer(1)?expand=Country", UriKind.Absolute)).First();

    MessageBox.Show(context.Entities.Count.ToString());




    Have you tried this?
    Monday, February 1, 2010 1:23 AM
  • Hi Jif,

     

    Thank you very much for following up on this thread.  I have tested your sample codes and I get 2 in the MessageBox.Show(), if there is a one-to-many relationship between the Country and Customer entities?  What result did you get?  

     

    Have a nice day!

     

     

    Best Regards,
    Lingzhi Sun

    MSDN Subscriber Support in Forum

    If you have any feedback on our support, please contact msdnmg@microsoft.com


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Monday, February 1, 2010 7:41 AM
    Moderator
  • After a bit more poking around I found where the inconsistency is, basically if you Attach an entity to the context then it sets the entities uri using the uri of the context.  All other cases the uri's are set by responses from the server so it may be different.

                // create a context
                Uri baseUri = new Uri("http://localhost:14808/server/northwindservice.svc/");
                NorthwindContext.NorthwindEntities context = new NorthwindContext.NorthwindEntities(baseUri);
    
                // attach a supplier
                NorthwindContext.Suppliers s = new NorthwindClient.NorthwindContext.Suppliers() { SupplierID = 1 };
                context.AttachTo("Suppliers", s);
    
                // fetch one supplier
                var entities1 = context.Suppliers.Where(x => x.SupplierID == 1).ToList();
    
                // should be 1, but it will be 2
                MessageBox.Show(context.Entities.Count.ToString());
    
    The Attach method seems to be of limited use in this case.

    Maybe using the full uri for an ID of an entity is not such a clever idea?  Could it be cut down to the entity type name and id?



    Friday, February 12, 2010 3:08 AM